Sunday 3 February 2019

arrays - VBA - looping through cells using "i"

I am trying to loop through a range on cells in a column and then check if the cell is empty, if it is, I want to copy the corresponding row into a new sheet. This is what I have so far:



    If Len(Cells(i, 17)) = 0 Then
Sheets("GES1").Activate
ActiveSheet.Range(Cells(i, 1), Cells(i, 17)).Select
Selection.Copy
Worksheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Paste
End If



Next i


The problem with this code is that as soon as there is an empty cell the corresponding row gets copied and pasted into a new sheet and the following rows also get copied and pasted into new sheets even if their corresponding cells are not blank. I want the code to copy and paste any row corresponding to an empty cell value in column Q i.e 17 to a single new sheet

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...