How to copy paste values to another sheet to next available dynamic blank rows using VBA

pankajgrover

Board Regular
Joined
Oct 27, 2022
Messages
157
Office Version
  1. 2021
Platform
  1. Windows
Hi I have data which i have to copy AH3 to AP25 to paste values to another sheet name saturday. But i want to paste these values to next available automatic dynamic empty rows in Saturday sheet because above i have already previous Saturday data. In below example in Saturday sheet , data should be paste in 6th or 7th row onwards. how to do that.. Thanks

Shares Trading.xlsm
AHAIAJAKALAMANAP
3TESTGold56324.00S14/01/2023156324.003650
4TESTSilver69427.00S14/01/2023169427.005480
Vishal
Cell Formulas
RangeFormula
AI3:AI4AI3=A3
AJ3:AJ4AJ3=D3
AK3:AK4AK3=F3
AP3:AP4AP3=IF(OR(AK3="",AN3=""),"",(H3-O3)*B3*D3+IF(AK3="S",-K3+AO3-Q3-J3+AR3,-AO3+R3-Q3-J3+AR3))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AL3:AN30Expression=$AK3="S"textNO
AL3:AN30Expression=$AK3="B"textNO
AK3:AK30Cell Value="B"textNO
AK3:AK30Cell Value="S"textNO


Saturday Sheet:

Shares Trading.xlsm
ABCDEFGH
3testGold55017S23/12/2022154574.00-44300
4testGold55017S23/12/2022154574.00-22150
5-66450
6
7
Saturday
Cell Formulas
RangeFormula
H5H5=SUM(H3:H4)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D3:D4,D8:D31,N3:N5Cell Value="B"textNO
D3:D4,D8:D31,N3:N5Cell Value="S"textNO
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
AH to AP is a total of 9 columns. A to H is 8 columns.
I noticed that column AO is missing from your original image.
Is it hidden? Do you not want to copy this column over?

And it looks like column H on your "Saturday" sheet sometimes has a total in it.
So is it safe to assume that when trying to locate the next available row, we should be looking at this column H, and not some other column, like A?
 
Upvote 0
AH to AP is a total of 9 columns. A to H is 8 columns.
I noticed that column AO is missing from your original image.
Is it hidden? Do you not want to copy this column over?

And it looks like column H on your "Saturday" sheet sometimes has a total in it.
So is it safe to assume that when trying to locate the next available row, we should be looking at this column H, and not some other column, like A?
Hi Morning, yes AO is hidden column, i don't want to copy this and Column H hv total at last and you should consider after that next available row. If possible there shoud be blank row after the total row before the new data paste here.
 
Upvote 0
Try this:
VBA Code:
Sub MyCopy2()

    Dim ws1 As Worksheet
    Dim ws2 As Worksheet
    Dim lr As Long
    
'   Set sheet to copy from
    Set ws1 = Sheets("Vishal")
'   Set sheet to copy to
    Set ws2 = Sheets("Saturday")
    
'   Find last row on with data in column H on Saturday sheet
    lr = ws2.Cells(ws2.Rows.Count, "H").End(xlUp).Row
    
'   Copy from AH3:AN3 to new range
    ws1.Range("AH3:AN25").Copy
    ws2.Range("A" & lr + 2).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        
'   Copy from AP3:AP25 to column H of new range
    ws1.Range("AP3:AP25").Copy
    ws2.Range("H" & lr + 2).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        
    Application.CutCopyMode = False
        
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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