0
votes

enter image description hereIm trying to construct a vba code which will clear content if cells = 0. However this depends on the previous vba code which changes the format of some cells. My code until now is:

Sub Macro1()

Application.DisplayAlerts = False

Dim lastRow As Variant

Range("A4:A65000").Select
Selection.TextToColumns Destination:=Range("B4"), DataType:=xlDelimited, _
    TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
    Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
    :="/", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1)), _
    TrailingMinusNumbers:=True
Range("B4").Select

 Range("E4:F4").AutoFill Destination:=Range("E4:F" & Range("A" & Rows.Count).End(xlUp).Row)

 lastRow = Range("A" & Rows.Count).End(xlUp).Row


  lastRow = lastRow + 1
  Rows(lastRow & ":F" & 2 ^ 20).ClearContents


  End Sub

So depending on the code i sometimes end up with a alot of cells containg "00" in row "G".

I thought i could use the code "Clearcontent", but im unsure to use it when the cells are adjusting all the time.

1

1 Answers

0
votes
  1. Locate last row in the column A. Last row in column VBA Lets say it is row 250. Let's say it is k
  2. Then write the following at the end:

k = k + 1
Rows(k & ":" & 2^20).ClearContents