Abdulkhadar
Board Regular
- Joined
- Nov 10, 2013
- Messages
- 165
- Office Version
- 2019
- 2010
- Platform
- Windows
Hello Excel Experts,
I want to add a code to clear all sheets data except sheet main (Sheet Name) from 4th row to last used row before updating the sheets in below VBA.
Thanks in advance
I want to add a code to clear all sheets data except sheet main (Sheet Name) from 4th row to last used row before updating the sheets in below VBA.
VBA Code:
Sub CopyData()
Application.ScreenUpdating = False
Dim bottomA As Long
bottomA = Range("F" & Rows.Count).End(xlUp).Row
Dim AccNum As Range
For Each AccNum In Range("F4:F" & bottomA)
Sheets(CStr(AccNum)).Cells(Rows.Count, "A").End(xlUp).Offset(1, 0) = AccNum.Offset(0, -4)
Sheets(CStr(AccNum)).Cells(Rows.Count, "B").End(xlUp).Offset(1, 0) = AccNum.Offset(0, -3)
Sheets(CStr(AccNum)).Cells(Rows.Count, "C").End(xlUp).Offset(1, 0) = AccNum.Offset(0, -2)
Sheets(CStr(AccNum)).Cells(Rows.Count, "D").End(xlUp).Offset(1, 0) = AccNum.Offset(0, 1)
Sheets(CStr(AccNum)).Cells(Rows.Count, "E").End(xlUp).Offset(1, 0) = AccNum.Offset(0, 3)
Next AccNum
Application.ScreenUpdating = True
End Sub
Thanks in advance
Last edited by a moderator: