I have a macro that opens files within a directory that start with a certain string. Then I clear the contents of one sheet to refresh the data with the macro. After that I switch to a different sheet and I want to clear the contents of only the bottom line. Later in the macro I may be adding more lines and then will replace the cleared line at the end of the macro. Here is the code that I am using.
The first part of the code works fine but it gets hung up on
returning a Run-Time error '13' Type Mismatch.
I recently modified the code that was working extending the range from 55 to 160. I ultimately want to delete the whole line or just the contents from column 1 to 160. what am I missing or doing wrong?
VBA Code:
Set fileNamesCollection = New Collection
MyFile = Dir(strx & "\*.xlsx", vbDirectory)
Do While MyFile <> ""
fileNamesCollection.Add MyFile
MyFile = Dir
Loop
For Each MyFile In fileNamesCollection
If Left(MyFile, 5) = "Rep S" Then
Set wbtemp = Workbooks.Open(strx & "\" & MyFile)
Sheets("POS Data").Range("A2: N2000 ").ClearContents
Set wstemp = wbtemp.Worksheets("POS Summary")
irow = wstemp.Cells(Rows.Count, 1).End(xlUp).Row
Sheets(wstemp).Range(wstemp.Cells(irow, 1), wstemp.Cells(irow, 160)).ClearContents
End If
Next
The first part of the code works fine but it gets hung up on
Code:
Sheets(wstemp).Range(wstemp.Cells(irow, 1), wstemp.Cells(irow, 160)).ClearContents
I recently modified the code that was working extending the range from 55 to 160. I ultimately want to delete the whole line or just the contents from column 1 to 160. what am I missing or doing wrong?