ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Excel Macro Question? (https://www.excelbanter.com/excel-discussion-misc-queries/98554-excel-macro-question.html)

Mike

Excel Macro Question?
 
Hi everyone,

I am trying to create two macros, macro1 copies from cell b3 and pastes
it in F6, and macro2 copies from cell b4 and pastes it in F7. I also
create two buttons; one for each macro.

Then I assign button1 for macro1 and button2 for macro2. When I try
each macro, I realize that each is copying from cell b4! In other
words, both macros are copying from b4 and pasting same thing in cells
F6 and F7!

Why, and how can I fix that?

Thanks,
Mike


Don Guillett

Excel Macro Question?
 
You could post your macros here for comments

--
Don Guillett
SalesAid Software

"Mike" wrote in message
oups.com...
Hi everyone,

I am trying to create two macros, macro1 copies from cell b3 and pastes
it in F6, and macro2 copies from cell b4 and pastes it in F7. I also
create two buttons; one for each macro.

Then I assign button1 for macro1 and button2 for macro2. When I try
each macro, I realize that each is copying from cell b4! In other
words, both macros are copying from b4 and pasting same thing in cells
F6 and F7!

Why, and how can I fix that?

Thanks,
Mike




Gary''s Student

Excel Macro Question?
 
Try these routines for your macros:

Sub mac1()
Set r1 = Range("B3")
Set r2 = Range("F6")
r1.Copy r2
End Sub
Sub mac2()
Set r1 = Range("B4")
Set r2 = Range("F7")
r1.Copy r2
End Sub
--
Gary's Student


"Mike" wrote:

Hi everyone,

I am trying to create two macros, macro1 copies from cell b3 and pastes
it in F6, and macro2 copies from cell b4 and pastes it in F7. I also
create two buttons; one for each macro.

Then I assign button1 for macro1 and button2 for macro2. When I try
each macro, I realize that each is copying from cell b4! In other
words, both macros are copying from b4 and pasting same thing in cells
F6 and F7!

Why, and how can I fix that?

Thanks,
Mike



Ken Johnson

Excel Macro Question?
 
Hi Mike,

If you used the macro recorder, was the referencing absolute or
relative?
If it was relative, then what is copied and where it is pasted depends
on the address of the selected cell when you ran the macro.
If it as absoute then it will always be B3 copied /pasted into F6 for
macro1 and B4 copied/pasted into F7 for macro2

Ken Johnson


Mike

Excel Macro Question?
 
I found the problem......thanks Don


Don Guillett wrote:
You could post your macros here for comments

--
Don Guillett
SalesAid Software

"Mike" wrote in message
oups.com...
Hi everyone,

I am trying to create two macros, macro1 copies from cell b3 and pastes
it in F6, and macro2 copies from cell b4 and pastes it in F7. I also
create two buttons; one for each macro.

Then I assign button1 for macro1 and button2 for macro2. When I try
each macro, I realize that each is copying from cell b4! In other
words, both macros are copying from b4 and pasting same thing in cells
F6 and F7!

Why, and how can I fix that?

Thanks,
Mike




All times are GMT +1. The time now is 10:30 AM.

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