Macro Help Archive Data

Dastnai

New Member
Joined
Oct 26, 2018
Messages
45
Hi Everyone,

I am attempting to copy data from one sheet to another. My copied data is A3:R52. However, i want it to paste the data at the next empty cell given there are not values everytime in A3:R52.


Here is my current code:

Range("A3:R52").Select
Selection.Copy
Sheets("Archived Data").Select
Range("A1").Select
Selection.End(xlDown).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("INQ Dashboard").Select
Application.CutCopyMode = False
Range("S3").Select
End Sub


Thanks for your help,

Dastnai
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hi,

Try:

Code:
Dim sht As Worksheet
Dim LastRow As Long


Set sht = Sheets("Archived Data")


LastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row


Range("A3:R52").Copy 
Sheets("Archived Data").Range("A" & LastRow).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False


Sheets("INQ Dashboard").Select
Application.CutCopyMode = False
Range("S3").Select


End Sub
 
Last edited:
Upvote 0
Hi,

Try:

Code:
Dim sht As Worksheet
Dim LastRow As Long


Set sht = Sheets("Archived Data")


LastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row


Range("A3:R52").Copy 
Sheets("Archived Data").Range("A" & LastRow).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False


Sheets("INQ Dashboard").Select
Application.CutCopyMode = False
Range("S3").Select


End Sub

I am getting an error here:

Dim sht As Worksheet
Dim LastRow As Long




Set sht = Sheets("Archived Data")




LastRow = sht.Cells(sht.rows.Count, "A").End(xlUp).Row




Range("A3:R52").Copy
Sheets("Archived Data").Range("A" & LastRow).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False




Sheets("INQ Dashboard").Select
Application.CutCopyMode = False
Range("S3").Select




End Sub
 
Upvote 0
apologies

Code:
Sub paste()


Dim sht As Worksheet
Dim LastRow As Long




Set sht = Sheets("Archived Data")
LastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row




Range("A3:R52").Copy
sht.Select
sht.Range("A" & LastRow).Select
Selection.PasteSpecial paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False




Sheets("INQ Dashboard").Select
Application.CutCopyMode = False
Range("S3").Select




End Sub
 
Upvote 0
apologies

Code:
Sub paste()


Dim sht As Worksheet
Dim LastRow As Long




Set sht = Sheets("Archived Data")
LastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row




Range("A3:R52").Copy
sht.Select
sht.Range("A" & LastRow).Select
Selection.PasteSpecial paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False




Sheets("INQ Dashboard").Select
Application.CutCopyMode = False
Range("S3").Select




End Sub

Unfortunately, this one is pasted the entire range. A bit stumped on this.
 
Upvote 0
Oh, I thought that was the goal.

Can you elaborate on
However, i want it to paste the data at the next empty cell given there are not values everytime

I took it to mean there were gaps in the sheet being pasted to and A1 with xldown wasn't finding the last row.

Some sample data would be helpful perhaps.
 
Last edited:
Upvote 0
Oh, I thought that was the goal.

Can you elaborate on

I took it to mean there were gaps in the sheet being pasted to and A1 with xldown wasn't finding the last row.

Some sample data would be helpful perhaps.

Thanks for your help Mrshl.

On my INQ Dashboard tab I am trying to copy range A3:R52. These cells all contain formulas. Some the output is a value or blank. My goal is to copy the range, paste as values into a new worksheet and to only paste the cells that are not blank. For instance, if I run my current code it copies and pastes the entire range so if I rerun the code it will now go to paste the next row of data 50 spots from the previous data inputted.
 
Upvote 0
Is it whole blank rows you are looking to exclude?



Code:
Sub paste()


Dim sht As Worksheet
Dim LastRow As Long


Set sht = Sheets("Archived Data")
LastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row


Range("A3:R52").Copy
sht.Select
sht.Range("A" & LastRow).Select
Selection.PasteSpecial paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete




Sheets("INQ Dashboard").Select
Application.CutCopyMode = False
Range("S3").Select


End Sub

If it's just blank cells, what do you want to happen to the data around the cell?
 
Last edited:
Upvote 0
if I rerun the code it will now go to paste the next row of data 50 spots from the previous data inputted.

It shouldn't be. Yours and mine both look for the last row containing data.

You could replace

Code:
[COLOR=#333333]Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete[/COLOR]

with

Code:
Cells.SpecialCells(xlCellTypeBlanks).EntireRow.Delete

if this is still happening, shouyld remove all blank rows from the destination sheet.
 
Upvote 0
It shouldn't be. Yours and mine both look for the last row containing data.

You could replace

Code:
[COLOR=#333333]Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete[/COLOR]

with

Code:
Cells.SpecialCells(xlCellTypeBlanks).EntireRow.Delete

if this is still happening, shouyld remove all blank rows from the destination sheet.

After I paste the data I am looking for it to allow me to paste again for the next row(s) of data. My current code there is a gap between the paste I was thinking a workaround was to delete blanks rows after. I am still getting an error. Would it be possible for me to send you a sample file?
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,244
Members
452,622
Latest member
Laura_PinksBTHFT

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