ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Copy Values with VBA (https://www.excelbanter.com/excel-discussion-misc-queries/115480-copy-values-vba.html)

Ed

Copy Values with VBA
 
Hello everyone, I would like to run a Macro that each time I do (by the way,
it will be used for printing and registering), right now I have this:

------------------------------------

Sub Print_Register()
'
' Keyboard Shortcut: Ctrl+Shift+P
'
Sheets("PRINT FORM").Select
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1
End Sub

-------------------------------------

To add a code that will copy certain values from "Sheet A" that acts as a
form (some of these values are =today() and vlookups and so on, so I need to
paste "As Value") into "Sheet B" that should act in a list-kind-of-way. I
need:

"Sheet A" to take K2 and put it into "Sheet B" A2
"Sheet A" to take K12 and put it into "Sheet B" B2
"Sheet A" to take E2 and put it into "Sheet B" C2
"Sheet A" to take M50 and put it into "Sheet B" D2

.... and so on...
and next time I run the macro to copy those values from Sheet A but now to
insert them into Row 3, then Row 4, then Row 5, and so on... (or if it is
possible to keep the last-entries-first-in-the-list order and so on that is
even better!)

any ideas?

,thanks!

Don Guillett

Copy Values with VBA
 
try this. Pls notice the use of . before the items in the with statement.
Also notice NO selections.

Sub Print_Register()
Keyboard Shortcut: Ctrl+Shift+P
with sheets("print_form")
.range("a2").value=range("k2")
.range("b2").value=range("k12")
.range("c2").value=range("e2")
.range("d2").value=range("m50")
.printout
end with
end sub
--
Don Guillett
SalesAid Software

"Ed" wrote in message
...
Hello everyone, I would like to run a Macro that each time I do (by the
way,
it will be used for printing and registering), right now I have this:

------------------------------------

Sub Print_Register()
'
' Keyboard Shortcut: Ctrl+Shift+P
'
Sheets("PRINT FORM").Select
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1
End Sub

-------------------------------------

To add a code that will copy certain values from "Sheet A" that acts as a
form (some of these values are =today() and vlookups and so on, so I need
to
paste "As Value") into "Sheet B" that should act in a list-kind-of-way. I
need:

"Sheet A" to take K2 and put it into "Sheet B" A2
"Sheet A" to take K12 and put it into "Sheet B" B2
"Sheet A" to take E2 and put it into "Sheet B" C2
"Sheet A" to take M50 and put it into "Sheet B" D2

... and so on...
and next time I run the macro to copy those values from Sheet A but now to
insert them into Row 3, then Row 4, then Row 5, and so on... (or if it is
possible to keep the last-entries-first-in-the-list order and so on that
is
even better!)

any ideas?

,thanks!




Ed

Copy Values with VBA
 
Thanks Don!


All times are GMT +1. The time now is 09:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com