Hey guys,
I'm not very good at VBA so I am asking for your help.
I want to run the following code everytime my UserForm is loaded.
I know where to put it but I am somehow not able to change it in a way that the cells are copied to the sheet "Data".
Hope you can help me with that.
Following the code:
Cheers
Jan
I'm not very good at VBA so I am asking for your help.
I want to run the following code everytime my UserForm is loaded.
I know where to put it but I am somehow not able to change it in a way that the cells are copied to the sheet "Data".
Hope you can help me with that.
Following the code:
Code:
Option Explicit
Private Sub Worksheet_Activate()
Dim ws As Worksheet
Dim lngLast As Long
Dim rngClear As Range
Set rngClear = Me.UsedRange
rngClear.Offset(1, 0).Resize(rngClear.Rows.Count - 1, rngClear.Columns.Count).Clear
Set rngClear = Nothing
For Each ws In Worksheets(Array("Inbound", "Outbound"))
lngLast = ws.Cells(Rows.Count, 1).End(xlUp).Row
With Me.Cells(Rows.Count, 1).End(xlUp)
ws.Range("D2:J" & lngLast).Copy Destination:=.Offset(1, 0)
.Offset(1, 0).Resize(lngLast - 1, 24).Value = _
ws.Range("D2:J" & lngLast).Value
End With
Next ws
End Sub
Cheers
Jan