MartinDurham
Board Regular
- Joined
- Feb 12, 2016
- Messages
- 70
Hi Folks
I have the following working VBS
It copies the data in D4 on the current sheet and writes it to 1st empty cell in column C of the specified sheet (or so I thought)
I have since modified the "»MaintenanceSchedule" (target) sheet so that the 1st of every 5 cells in row c is blank like so:
9
10 =IF(ISBLANK(C9),"",(C9))
11 =IF(ISBLANK(C9),"",(C9))
12 =IF(ISBLANK(C9),"",(C9))
13 =IF(ISBLANK(C9),"",(C9))
It now writes the value to the very end of column C instead of the 1st empty one (in this case it should be C9), so it would seem I misunderstand what this VBS is actually doing.
any help is greatly appreciated
Martin
I have the following working VBS
Code:
Sub SaveVehicleChanges2()
LastRow = Sheets("»MaintenanceSchedule").Cells(Rows.Count, "C").End(xlUp).Row + 1
If Application.WorksheetFunction.CountIf(Sheets("»MaintenanceSchedule").Range("C1:C" & LastRow), ActiveSheet.Range("D4").Value) = 0 Then
ActiveSheet.Range("D4").Copy Destination:=Sheets("»MaintenanceSchedule").Range("C" & LastRow)
LastRow = LastRow + 1
MsgBox "Vehicle Added"
Else
MsgBox "Changes Saved"
End If
End Sub
It copies the data in D4 on the current sheet and writes it to 1st empty cell in column C of the specified sheet (or so I thought)
I have since modified the "»MaintenanceSchedule" (target) sheet so that the 1st of every 5 cells in row c is blank like so:
9
10 =IF(ISBLANK(C9),"",(C9))
11 =IF(ISBLANK(C9),"",(C9))
12 =IF(ISBLANK(C9),"",(C9))
13 =IF(ISBLANK(C9),"",(C9))
It now writes the value to the very end of column C instead of the 1st empty one (in this case it should be C9), so it would seem I misunderstand what this VBS is actually doing.
any help is greatly appreciated
Martin
Last edited: