2 simple vb questions

Status
Not open for further replies.

tuktuk

Well-known Member
Joined
Nov 13, 2006
Messages
856
I have 2 pretty easy ?'s but i can't figure em out.....

1). if you have a cell selected, how do you code it to move down 1 row.

Code:
Dim LastRowDB As Long
LastRowDB = Cells(Rows.Count, "D").End(xlUp).Row
Range("A" & LastRowDB).Select

'NEED HELP HERE.goal is to move the actice cell down ONE ROW
ActiveCell.MoveDown

2). if you have a range selected, how to you code it to paste.

Code:
'Copy CurrentDays Invoices
LastRowPO = Cells(Rows.Count, "D").End(xlUp).Row
Range("A2:M" & LastRowPO).Select
Selection.Copy

'Open the CompilingMaster tab (database) file
Workbooks("POQuantityTrackingReport.xls").Activate

'NEED HELP HERE.goal is to simple paste the Selection from above
Selection.Paste
'also tried
ActiveCell.Paste
 

Some videos you may like

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

schielrn

Well-known Member
Joined
Apr 4, 2007
Messages
6,939
For the 2nd one try Activesheet.Paste -- You may have to select the sheet if its not the sheet it is on when you activate the workbook.

For the first one you can use:

ActiveCell.Offset(-1, 0).Select

Hopefully those should work for you.
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
It's not generally necessary to select ranges, you can work with ranges directly in VBA.

Something like this:

Code:
Sub test()
Dim LastRowPO As Long
'Copy CurrentDays Invoices
LastRowPO = Cells(Rows.Count, "D").End(xlUp).Row
Range("A2:M" & LastRowPO).Copy Workbooks("POQuantityTrackingReport.xls").Sheets("Sheet1").Range("A2")
End Sub
 
Status
Not open for further replies.

Watch MrExcel Video

Forum statistics

Threads
1,123,402
Messages
5,601,475
Members
414,452
Latest member
Dannysamworth

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
Top