2 simple vb questions

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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Oorang

Well-known Member
Joined
Mar 4, 2005
Messages
2,071
ActiveCell.Insert Shift:=xlDown
Selection.Copy Destination:=Range("A1")
 

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
First off, most things can be done without selecting...but anyway..

1.
Range("A" & LastRowDB).Offset(1, 0).Select

2.
Range("A1").Select ' You first have to tell it where to paste
ActiveSheet.Paste
 

tuktuk

Well-known Member
Joined
Nov 13, 2006
Messages
856
hmmmm....i guess the "ActiveCell.Insert Shift:=xlDown" command works but i do not want it to move the data within the cell........but i tput the active cell where i want it. ANY IDEAS?

still working on part 2
 

tuktuk

Well-known Member
Joined
Nov 13, 2006
Messages
856
i thought i add the whole code to give a complete understanding

Code:
Sub UpdatePOQntyReducDB()
Dim lookupfilename As String
lookupfilename = "\\Sr\SharedDocs\CSPSharedFILES\POQuantityTrackingTool\POQuantityTrackingReport.xls"

Workbooks.Open lookupfilename
Workbooks("POQuantityTrackingReport.xls").Activate

'locate the cell in first column +1 cell past the previous days upload
'this preps for the next upload
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
ActiveCell.Insert Shift:=xlDown

'Open the Current Days Invoices
Workbooks("POQntyReductionTool3.xls").Activate

Dim LastRowPO As Long

'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
'this was the posting form MrExcel but is the incorrect location
'Selection.Copy Destination:=Range("A1")

Selection.Paste Destination:=Range("A1")


ActiveWorkbook.Save
ActiveWorkbook.Close

Workbooks("POQntyReductionTool3.xls").Activate
Range("A1").Select
MsgBox ("Today's invoices have been updated to the POQuantiyTrackingReport.")

End Sub
 

Oorang

Well-known Member
Joined
Mar 4, 2005
Messages
2,071
The insert method works on any Range object. You can define a range object two ways:
Code:
'One Way:
ThisWorkBook.Worksheets("Sheet1").Range("A1").Insert Shift:=xlDown 
'Another Way
Dim rng as Excel.Range
set rng = Thisworkbook.Worksheets("Sheet1").Range("A1:A10")
rng.Insert Shift:=xlDown
 

Seti

Well-known Member
Joined
May 19, 2002
Messages
2,916
How about this?

Range("A" & LastRowDB + 1).Select
 

Forum statistics

Threads
1,181,648
Messages
5,931,212
Members
436,784
Latest member
amuljono

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