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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
ActiveCell.Insert Shift:=xlDown
Selection.Copy Destination:=Range("A1")
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,165
Members
448,870
Latest member
max_pedreira

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