vbanewbie68
Board Regular
- Joined
- Oct 16, 2021
- Messages
- 171
- Office Version
- 365
- Platform
- Windows
- MacOS
Hello
I have been given a macro to transform an original data from a platform website into a imported report for our database.
In one area in the sub statement as see below I am struggling to read that and feel its not readable to me.
I don't under what is FirstR = 0 and LastR = 0.
Can you help me to read this please?
I have been given a macro to transform an original data from a platform website into a imported report for our database.
In one area in the sub statement as see below I am struggling to read that and feel its not readable to me.
I don't under what is FirstR = 0 and LastR = 0.
Can you help me to read this please?
VBA Code:
Sub CopyData()
lastimport = mbook.Sheets("ImportDates").Cells(1, 1).End(xlDown).Value
Set tempsht = tempbook.Sheets(1)
FirstR = 0
LastR = 0
dateC = findCol("EventDate", tempsht)
For x = 2 To tempsht.Cells(1, 1).End(xlDown).Row
If FirstR = 0 And tempsht.Cells(x, dateC) > lastimport Then
FirstR = x
End If
If tempsht.Cells(x, dateC).Value < Date Then
LastR = x
End If
Next x
If FirstR > 0 Then
mbook.Sheets("ImportDates").Cells(1, 1).End(xlDown).Offset(1, 2).Value = LastR - FirstR - 1
mbook.Sheets("ImportDates").Cells(1, 1).End(xlDown).Offset(1, 1).Value = Date
mbook.Sheets("ImportDates").Cells(1, 1).End(xlDown).Offset(1, 0).Value = Date - 1
Else
MsgBox ("No new rows to import. If this is wrong check the 'LastImportDates' sheet")
tempbook.Close SaveChanges:=False
End
End If
rsheet.Activate
tempsht.Rows(FirstR & ":" & LastR).Copy rsheet.Cells(2, 1)
End Sub
Last edited by a moderator: