All,
I pretty much have the code together, but i'm struggling with getting the code from Sheet "Data" to sheet "FAI"
output of data from spreadsheet on "Data" tab is shown below.
VBA Code below
The code runs properly, but I do not see the output onto the FAI sheet location C4.
I pretty much have the code together, but i'm struggling with getting the code from Sheet "Data" to sheet "FAI"
output of data from spreadsheet on "Data" tab is shown below.
Date | Part Number | Supplier | Rev | RI Code |
5/3/2022 | C073061-D-F | BLABLA | D | E06 |
5/3/2022 | C073061-D-F | BLABLA | D | E06 |
5/3/2022 | C073061-D-F | BLABLA | D | E06 |
5/3/2022 | C073061-D-F | BLABLA | D | E06 |
5/3/2022 | C073061-D-F | BLABLA | D | E06 |
VBA Code below
VBA Code:
'Write the recordset values in the sheet.
Worksheets("Data").Range("A2").CopyFromRecordset rs
'transfer from data tab to fai log
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Worksheets("data").Activate
'Dim cell As Range
Dim rng As Range
Dim shtSrc As Worksheet, shtDest As Worksheet
Dim ite
Dim myDate As Date
myDate = Application.Max(Columns(1))
ActiveSheet.AutoFilterMode = False
Columns(1).AutoFilter Field:=1, Criteria1:=Format(myDate, [A2].NumberFormat)
Set shtSrc = Worksheets("Data") ' Sets "Sheet1" sheet as source sheet
Set shtDest = Worksheets("FAI") 'Sets "Sheet2." sheet as destination sheet
Set rng = Range("B2", Range("B65536").End(xlUp)).SpecialCells(xlCellTypeVisible)
ite = Me("Part" & a)
For Each cell In rng
If cell = ite Then
Sheets("Data").Range("B" & rng).Value = Worksheets("FAI").Range("C4").Value
End If
Next cell
'Close the recordset and the connection.
rs.Close
cnn.Close
'clear memory
Set rs = Nothing
Set cnn = Nothing
'loop
Next a
done2:
'Enable the screen.
Application.ScreenUpdating = True
'Inform the user that the macro was executed successfully.
MsgBox "Congratulation the data has been successfully Imported", vbInformation, "Import successful"
Worksheets("PSW").Activate
Unload Me
'error handler
On Error GoTo 0
Exit Sub
errHandler:
'clear memory
Set rs = Nothing
Set cnn = Nothing
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Import_Data"
The code runs properly, but I do not see the output onto the FAI sheet location C4.