Eric Penfold
Active Member
- Joined
- Nov 19, 2021
- Messages
- 431
- Office Version
- 365
- Platform
- Windows
- Mobile
Please see code below to find last row in column c in a Excel Table. How can I alter the code to work?
VBA Code:
LRow = tblDailyMail.Cells(Rows.Count, 3).End(xlUp).Row
VBA Code:
Sub Mouthly_DailyMail_Figurers()
Dim CopyToRange As Range
Dim PasteToRange As Range
Dim Rng As Range
Dim Cell As Range
Dim LRow As Long
Dim wb As Workbook
Dim swb As Workbook
Dim sws As Worksheet
Dim ws As Worksheet
Dim tblDailyMail As Object
Dim FileToOpen As Variant
With Application
.ScreenUpdating = False
.Calculation = xlManual
.DisplayAlerts = False
End With
Set swb = ActiveWorkbook
Set sws = swb.Worksheets("Sheet")
FileToOpen = ("S:\SALES\REPORTING\2023\Daily Mail.xlsx")
Workbooks.Open FileToOpen
Set wb = Workbooks("Daily Mail.xlsx")
Set ws = wb.Worksheets("Daily Mail Update")
Set CopyToRange = sws.Range("A2")
With ws
Set tblDailyMail = .ListObjects("Daily_Mail_Data")
LRow = tblDailyMail.Cells(Rows.Count, 3).End(xlUp).Row
Set PasteToRange = tblDailyMail.Range("C5:C" & LRow)
For Each Cell In PasteToRange
If Not WorksheetFunction.IsText(Cell.Value) Then
Cell.Value = CopyToRange.Value
Cell.Font.Name = "Arial"
Cell.Font.Size = 11
End If
Next Cell
.Range("H25") = CopyToRange
.Range("I25") = sws.Range("B2")
End With
Call DalyMailUpdate
Workbooks("Daily Mail.xlsx").Save
' Workbooks("Daily Mail.xlsx").Close
With Application
.ScreenUpdating = True
.Calculation = xlAutomatic
.DisplayAlerts = True
End With
MsgBox ("Daily Mail Mountly Figurers Updated")
End Sub