Excel VBA to paste to new line after entry

Status
Not open for further replies.

jfrancis

New Member
Joined
Nov 7, 2013
Messages
9
I'm trying to make a sales quotation entry process simpler by using macros. This code below works, but it goes horizontally across the sheet instead of going vertically down the columns.

I have dynamic data (from vlookup) generated in cell G3 and I've made a button to copy this data from G3 and paste the value to column A1. As of now, upon clicking the assigned macro button, it pastes data from, G3 to H3, I3, J3, K3 and so on. I need the macro to copy-paste from G3 to the cell directly below, like A1, A2, A3, A4 and so on... :)

Code:
Sub paste2()
' paste2 Macro
    Dim lastCol As Long
' this finds the number of the last column
lastCol = Cells(3, Columns.Count).End(xlToLeft).Column


   Range("G3").Copy


Range("A1").Select
   Cells(3, lastCol + 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
End Sub
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Rich (BB code):
Rows(7).Value = Rows(5).Value
the formula is almost working but there is only one thing wrong, the code doesnt copy the range (A5:DG5) IT SIMPLY COPY RANDOM NUMBERS


Sub paste()
' paste2 Macro
Dim lastRow As Long
' this finds the number of the last row
Rows(7) = Cells(Rows.Count, 5).End(xlUp).Row
Range("A5:DG5").Copy
Cells(lastRow + 1, 1).PasteSpecial paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("7:7").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End Sub
 
Upvote 0
the formula is almost working but there is only one thing wrong, the code doesnt copy the range (A5:DG5) IT SIMPLY COPY RANDOM NUMBERS


Sub paste()
' paste2 Macro
Dim lastRow As Long
' this finds the number of the last row
Rows(7) = Cells(Rows.Count, 5).End(xlUp).Row
Range("A5:DG5").Copy
Cells(lastRow + 1, 1).PasteSpecial paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("7:7").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End Sub
 

Attachments

  • Capturar.PNG
    Capturar.PNG
    26.8 KB · Views: 8
Upvote 0
Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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