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
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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.
 
Upvote 0
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
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,211,680
Messages
6,103,251
Members
447,850
Latest member
thebuzzman15

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