Johnny Thunder
Well-known Member
- Joined
- Apr 9, 2010
- Messages
- 693
- Office Version
- 2016
- Platform
- MacOS
Hello,
I am working on a project that requires 3 blocks of data (1 Column) one after the other.
I thought I could use the LastRow Syntax to get this done but it seems to not be updating after I paste the first block on my spreadhseet.
My code so far with comments is below. Any help is appreciated
I am working on a project that requires 3 blocks of data (1 Column) one after the other.
I thought I could use the LastRow Syntax to get this done but it seems to not be updating after I paste the first block on my spreadhseet.
My code so far with comments is below. Any help is appreciated
Rich (BB code):
Sub CopyBlocks()
Dim LastR As Long, LastRC As Long, lastR2 As Long, LastR3 As Long, lastR4 As Long
Dim Sht As Worksheet, sht2 As Worksheet, sht3 As Worksheet, sht4 As Worksheet
Dim myloop
Set Sht = Sheet5 'Recon
Set sht2 = Sheet1 'BPC
Set sht3 = Sheet3 'BW
Set sht4 = Sheet4 'Journals
LastR = Sht.Cells(Rows.Count, "B").End(xlUp).Row 'sheet where the blocks need to go
lastR2 = sht2.Cells(Rows.Count, "B").End(xlUp).Row 'Block 1 Data
LastR3 = sht3.Cells(Rows.Count, "C").End(xlUp).Row 'Block 2 Data
lastR4 = sht4.Cells(Rows.Count, "C").End(xlUp).Row 'Block 3 Data
LastRC = Sht.Cells(Rows.Count, "A").End(xlUp).Row 'Redim's the last row after each paste - Currently not working
Application.ScreenUpdating = False
sht2.Range("A12:A" & lastR2 & "").Copy 'Block #1
Sht.Range("A11").PasteSpecial xlValues 'Start of 1st paste location
Application.CutCopyMode = False
MsgBox LastRC 'To see if the lastrow updated
sht3.Range("B19:B" & LastR3 & "").Copy 'Block #2
Sht.Range("A" & LastRC + 1 & "").PasteSpecial xlValues 'Finds the new LastRow in Col A
Application.CutCopyMode = False
MsgBox LastRC 'To see if the lastrow updated
sht4.Range("A14:A" & lastR4 & "").Copy 'Block #3
Sht.Range("A" & LastRC + 1 & "").PasteSpecial xlValues 'Finds the new LastRow in Col A
Application.CutCopyMode = False
Calculate
Application.ScreenUpdating = True
End Sub