VBA code to go for next row

shashipal

New Member
Joined
Jul 24, 2023
Messages
7
Office Version
  1. 2010
Platform
  1. Windows
Hi all,

Im new to VBA coding. Plz help me to solve this. im unable to find solution on google.

First i need to enter below values.
H1 is part Number
H2 is qty.

Then after i click on "Paste" button, my macro will executed.
As per macro it will copy data from K2 & L2(these cells values change) and paste it in N2 & O2.

its working fine.

My problem: Again after next selection my new data should paste in N3 & O3. But as per my macro again it paste in N2 & O2

First my VBA code need to check weather N2 & O2 is blank or not. if blank paste. if not balank goto N3 & O3 i.e next row.. so on..

Plz can anyone write code for that and help me.

PFA: my vba code and screenshot.

Sub Macro2()
'
' Macro2 Macro
'

'
Range("K2:L2").Select
Selection.Copy
Range("N2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub


Thanks in advance.
excel macro.jpg
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Welcome to the MrExcel board!

Try
VBA Code:
Sub Test()
  Range("N" & Rows.Count).End(xlUp).Offset(1).Resize(, 2).Value = Range("K2:L2").Value
End Sub
 
Upvote 1
Solution
You are welcome. Thanks for the follow-up. :)
 
Upvote 1

Forum statistics

Threads
1,215,084
Messages
6,123,029
Members
449,092
Latest member
ikke

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