Trying to paste to the next available line that is empty

Howey

New Member
Joined
Sep 16, 2022
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

New to Mr Excel and hoping you can help with the below, i have recorded a macro to copy values from from one tab and paste them into a row "A" on the next tab and i found a string which is supposed to paste all the data to the next available row when the macro runs but it is pasting to the first row each time,
can some one help,

Sheets("Matrix").Select
ActiveSheet.Unprotect
Sheets("Raise a CI").Select
Range("B6").Select
Selection.Copy
Sheets("Matrix").Range("A" & Rows.Count).End(xlUp).Offset(1).
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Raise a CI").Select
Range("B3").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Matrix").Select
Range("B2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Try this -

VBA Code:
Sheets("Matrix").Select
ActiveSheet.Unprotect
Sheets("Raise a CI").Select
Range("B6").Select
Selection.Copy
Sheets("Matrix").Range("A" & Rows.Count).End(xlUp).Offset(1).
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Raise a CI").Select
Range("B3").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Matrix").Select
Range("B2").Select

'To go to last row of the same Active column
Dim LRow As Long, LCol As Long
LCol = ActiveCell.Column
LRow = Cells(Rows.Count, LCol).End(xlUp).Row
Cells(LRow, LCol).Select

'To paste at selected cell
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
 
Upvote 0
How about:
VBA Code:
Sub CopyData()
    With Sheets("Raise a CI")
        .Range("B6").Copy
        With Sheets("Matrix")
            .Unprotect
            .Cells(.Rows.Count, "A").End(xlUp).Offset(1).PasteSpecial xlPasteValues
        End With
        .Range("B3").Copy
        With Sheets("Matrix")
            .Cells(.Rows.Count, "B").End(xlUp).Offset(1).PasteSpecial xlPasteValues
        End With
    End With
    Application.CutCopyMode = False
End Sub
 
Upvote 0
Posting here hoping that someone can point me in the right direction.... I have VBA Code that Copy and Pastes but it seems that my final results in column D has all of column B and tones of blank rows and then entries from column C. I know there is something in my code that capturing all these blank row, I just don't know what/how to fix it. Any suggestions?

Columns("B:C").EntireColumn.Hidden = False
ActiveSheet.Range("$A$1:$E$50").AutoFilter Field:=2, Criteria1:="<>"
Range("B2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
ActiveWindow.LargeScroll ToRight:=1
ActiveWindow.SmallScroll ToRight:=1
Range("D2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=True, Transpose:=False
ActiveWindow.SmallScroll ToRight:=-2
Call Application.Calculate
ActiveSheet.Range("$A$1:$E$50").AutoFilter Field:=2
LastRow = ActiveWorkbook.Worksheets("Rename_Folders").Cells(Rows.Count, 4).End(xlUp).Row
NextRowExport = LastRow + 1

ActiveWorkbook.Worksheets("Rename_Folders").Range("C2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy

ActiveWorkbook.Worksheets("Rename_Folders").Range("D" & NextRowExport).PasteSpecial xlPasteValues
Call Application.Calculate
Columns("B:C").EntireColumn.Hidden = True
Range("D2").Activate
 
Upvote 0
Please start your own new thread. You will increase your chances of getting a solution.
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,283
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top