Hi,
Can someone help me with my code. File attached. I was trying to modify an existing code I have to make it to work and could not figure out. The old code is below. Main difference is that on this current file I need the code to copy the entire table (table name - panelbundle) instead of specific cells.
Code is in module 1 - loginventory in the attached file
Module 2 I made it to work just fine.
Put a quick explanation in the Log Inventory tab to clarify what I'm trying to do.
I appreciate much any help. Kind regards, Natalia
Old code I was trying to modify is as follows:
Sub UpdateLogWorksheet()
Dim historyWks As Worksheet
Dim inputWks As Worksheet
Dim nextRow As Long
Dim previousRow As Long
Dim oCol As Long
Dim myRng As Range
Dim myCopy As String
Dim myCell As Range
Dim coatercoil As Integer
Dim coaterlocation As String
'cells to copy from Input sheet - some contain formulas
myCopy = "b2,b4,b10,b12,b14,b16,b8,e10,e12,e14,e16,b20,e20,h20,b18"
Set inputWks = Worksheets("Received Coil Input")
Set historyWks = Worksheets("Bare Log")
coatercoil = inputWks.Cells(22, 2).Value
coaterlocation = inputWks.Cells(24, 2).Value
With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
previousRow = nextRow - 1
End With
With inputWks
Set myRng = .Range(myCopy)
End With
With historyWks
With .Cells(nextRow, "A")
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
.Cells(nextRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
historyWks.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With
'clear input cells that contain constants
With inputWks
On Error Resume Next
With .Range(myCopy).Cells.SpecialCells(xlCellTypeConstants)
.ClearContents
Application.GoTo .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With
historyWks.Cells(nextRow, 15).FormulaR1C1 = historyWks.Cells(previousRow, 15).FormulaR1C1
historyWks.Cells(nextRow, 18).FormulaR1C1 = historyWks.Cells(previousRow, 18).FormulaR1C1
historyWks.Cells(nextRow, 23).Value = coatercoil
historyWks.Cells(nextRow, 24).Value = coaterlocation
inputWks.Cells(22, 2).ClearContents
inputWks.Cells(24, 2).ClearContents
End Sub
Bookmarks