ProT
New Member
- Joined
- Feb 22, 2022
- Messages
- 1
- Office Version
- 365
- 2021
- 2019
- Platform
- Windows
- MacOS
- Mobile
Hello, I am new to vba and I want to create a proxy for missing data in my workbook, so I would like to use the data from the previous date's workbook. I need to find the same names in column G of the previous date workbook copy their row from column D and paste it in my current workbook.
I am able to create a unique names array but not able to create the for loops and the if conditions. The unique array is created by the missing values.
The structure in both workbooks is the same but I do not need to copy-paste the first four columns. Below you can find what I have done so far.
I am able to create a unique names array but not able to create the for loops and the if conditions. The unique array is created by the missing values.
The structure in both workbooks is the same but I do not need to copy-paste the first four columns. Below you can find what I have done so far.
VBA Code:
Sub unique()
Dim unique As Variant
Dim Fname As String
unique = WorksheetFunction.unique(Worksheets(2).Range("G:G"))
dat = Worksheets("Summary").Range("c3")
tempDate = DateAdd("d", -1, dat) 'Today's date - 1
While Weekday(tempDate) = 1 Or Weekday(tempDate) = 7
'If tempDate is a Sunday or a Saturday, keep on subtracting one day until we get a weekday
tempDate = DateAdd("d", -1, tempDate)
Wend
Fname = "path?" & ".xlsm"
Set wb2 = Workbooks.Open(Fname)
Set col2 = wb2.Sheets("Summary").Range("G:G")
' Here is what I should figure out
For Each cell In col2
' ......................
End If
Next cell
wb2.Close SaveChanges:=False
End Sub