I'm not trained in vba and would be very grateful for advice about the following Thanks Geoff
I have 2 columns of data; left date & time, right col with half hourly meter readings. From a start date I need to run down the left column to find the last entry of the first date then copy the readings fromt he right col and paste them into a new sheet as a row & then repeat the process so that the data is in rows by date until I've copied all of the data. I've got a loop to read and compare the date cells row by row & an if statement. I'm getting an error warning that the first " Next a " needs a For.
Within the structure of the code I have :
'do the following until cell in col A is blank ' Select cell startdate, first line of data ' Set loop to stop when an empty cell is reached
For a = 1 To LastRow Step 1
checkdate = DateValue("A" & startdaterow + a)
If startdate = checkdate Then
Next a
Else: Range("B" & startdate.Row, "B" & startdaterow + a).Copy
Sheets("Output").Select
Range("C" & b + 1).PasteSpecial
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
.Cells(b & "B") = startdate
b = b + 1
startdaterow = startdaterow + a
enddaterow = enddaterow + a
Range("B" & enddaterow).Select
Next a
End If
Aucun commentaire:
Enregistrer un commentaire