MongeredRue
New Member
- Joined
- Jan 14, 2019
- Messages
- 3
I run a report on a weekly basis, via separate software, and I have to distribute the data from the report into the corresponding sheets. I'm trying to do this in VBA, because i'm sick of doing it by hand, but I'm getting stuck on the most critical part: cutting the data and pasting it to the appropriate sheet. Any help would be appreciated!!
Code:
Worksheets("Working Sheet").Activate
Dim ws As Worksheet
Dim LR As Long, LR2 As Long, x As Long, i As Long
Application.ScreenUpdating = False
With Sheets("Working Sheet")
LR = .Range("B" & .Rows.Count).End(xlUp).Row
x = .Cells(1, Columns.Count).End(xlToLeft).Column
End With
For Each ws In ActiveWorkbook.Sheets
If ws.Name <> "Working Sheet" Then ws.Cells.ClearContents
Next ws
For Each ws In ActiveWorkbook.Sheets
With ws
LR2 = .Range("B" & .Rows.Count).End(xlUp).Row + 1
For i = 1 To LR
If ws.Name = Sheets("Working Sheet").Range("B" & 1).Value Then
.Rows(i).Cut Destination:=Sheets(ws.Name).Range("A" & Rows.Count).End(xlUp).Offset(1)
Exit For
End If
Next i
End With
Next ws
Application.ScreenUpdating = True