#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Macro Help

I am a novice at macros and need a little help.

In Tab 1 I have a value in cell H35.

What I want to do is have the Macro go to Cell h38 in Tab 2 and have that
cell put a formula to reference cell H35 on Tab 1. Then in Cell I38:AD38 in
Tab 2 I want it to reference cell h38 of Tab 2.

I tried to record a Macro to do this and it keeps giving me errors. I have
tried switching between relative reference and not and I still have an
error. So obviously I am doing something wrongs. Anyone have a code that
will enable me to do this.

Thanks in advance.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Macro Help

Hi Craig,

Try something like this:

Worksheets("Sheet2").Range("H38").Formula = "=Sheet1!$H$35"
Worksheets("Sheet2").Range(Cells(38, 9), Cells(38, 30)).Formula = "=$H$38"

Change the Sheet2 and Sheet1 to your tab names. I have simply referenced the
cells directly as your question requests. Obviously you can now amend the
formula to represent any worksheet function you need.

Hope this helps,

Sean.

--
(please remember to click yes if replies you receive are helpful to you)


"Craig" wrote:

I am a novice at macros and need a little help.

In Tab 1 I have a value in cell H35.

What I want to do is have the Macro go to Cell h38 in Tab 2 and have that
cell put a formula to reference cell H35 on Tab 1. Then in Cell I38:AD38 in
Tab 2 I want it to reference cell h38 of Tab 2.

I tried to record a Macro to do this and it keeps giving me errors. I have
tried switching between relative reference and not and I still have an
error. So obviously I am doing something wrongs. Anyone have a code that
will enable me to do this.

Thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Macro Help

I copied your code exactly and it gives me an error for the second line of
code:

Worksheets("Sensitivity").Range(Cells(38, 9), Cells(38, 30)).Formula =
"=$H$38"

Thie first line worked correctly, but for some reason it doesn't like this.
Any other ideas.

thanks!




"SeanC UK" wrote in message
...
Hi Craig,

Try something like this:

Worksheets("Sheet2").Range("H38").Formula = "=Sheet1!$H$35"
Worksheets("Sheet2").Range(Cells(38, 9), Cells(38, 30)).Formula = "=$H$38"

Change the Sheet2 and Sheet1 to your tab names. I have simply referenced
the
cells directly as your question requests. Obviously you can now amend the
formula to represent any worksheet function you need.

Hope this helps,

Sean.

--
(please remember to click yes if replies you receive are helpful to you)


"Craig" wrote:

I am a novice at macros and need a little help.

In Tab 1 I have a value in cell H35.

What I want to do is have the Macro go to Cell h38 in Tab 2 and have that
cell put a formula to reference cell H35 on Tab 1. Then in Cell I38:AD38
in
Tab 2 I want it to reference cell h38 of Tab 2.

I tried to record a Macro to do this and it keeps giving me errors. I
have
tried switching between relative reference and not and I still have an
error. So obviously I am doing something wrongs. Anyone have a code
that
will enable me to do this.

Thanks in advance.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Macro Help

OK, I'm not sure why that's not working. Try one of these instead:

replace
Worksheets("Sensitivity").Range(Cells(38, 9), Cells(38, 30)).Formula =
"=$H$38"

with
Worksheets("Sensitivity").Range("I38:AD38").Formul a = "=$H$38"

Or try this instead, so as to loop through each cell in your range:

Dim MyRange As Range
Worksheets("Sensitivity").Range("H38").Formula = "=Sheet1!$H$35"
For Each MyRange In Worksheets("Sensitivity").Range("I38:AD38")
MyRange.Formula = "=$H$38"
Next

(Change Sheet1 as necessary)

If you're still getting troubles then let me know the Excel version and the
error number/description.

Sean.



--
(please remember to click yes if replies you receive are helpful to you)


"Craig" wrote:

I copied your code exactly and it gives me an error for the second line of
code:

Worksheets("Sensitivity").Range(Cells(38, 9), Cells(38, 30)).Formula =
"=$H$38"

Thie first line worked correctly, but for some reason it doesn't like this.
Any other ideas.

thanks!




"SeanC UK" wrote in message
...
Hi Craig,

Try something like this:

Worksheets("Sheet2").Range("H38").Formula = "=Sheet1!$H$35"
Worksheets("Sheet2").Range(Cells(38, 9), Cells(38, 30)).Formula = "=$H$38"

Change the Sheet2 and Sheet1 to your tab names. I have simply referenced
the
cells directly as your question requests. Obviously you can now amend the
formula to represent any worksheet function you need.

Hope this helps,

Sean.

--
(please remember to click yes if replies you receive are helpful to you)


"Craig" wrote:

I am a novice at macros and need a little help.

In Tab 1 I have a value in cell H35.

What I want to do is have the Macro go to Cell h38 in Tab 2 and have that
cell put a formula to reference cell H35 on Tab 1. Then in Cell I38:AD38
in
Tab 2 I want it to reference cell h38 of Tab 2.

I tried to record a Macro to do this and it keeps giving me errors. I
have
tried switching between relative reference and not and I still have an
error. So obviously I am doing something wrongs. Anyone have a code
that
will enable me to do this.

Thanks in advance.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Macro Help

That worked. Thanks for the help!!!!!!


"SeanC UK" wrote in message
...
OK, I'm not sure why that's not working. Try one of these instead:

replace
Worksheets("Sensitivity").Range(Cells(38, 9), Cells(38, 30)).Formula =
"=$H$38"

with
Worksheets("Sensitivity").Range("I38:AD38").Formul a = "=$H$38"

Or try this instead, so as to loop through each cell in your range:

Dim MyRange As Range
Worksheets("Sensitivity").Range("H38").Formula = "=Sheet1!$H$35"
For Each MyRange In Worksheets("Sensitivity").Range("I38:AD38")
MyRange.Formula = "=$H$38"
Next

(Change Sheet1 as necessary)

If you're still getting troubles then let me know the Excel version and
the
error number/description.

Sean.



--
(please remember to click yes if replies you receive are helpful to you)


"Craig" wrote:

I copied your code exactly and it gives me an error for the second line
of
code:

Worksheets("Sensitivity").Range(Cells(38, 9), Cells(38, 30)).Formula =
"=$H$38"

Thie first line worked correctly, but for some reason it doesn't like
this.
Any other ideas.

thanks!




"SeanC UK" wrote in message
...
Hi Craig,

Try something like this:

Worksheets("Sheet2").Range("H38").Formula = "=Sheet1!$H$35"
Worksheets("Sheet2").Range(Cells(38, 9), Cells(38, 30)).Formula =
"=$H$38"

Change the Sheet2 and Sheet1 to your tab names. I have simply
referenced
the
cells directly as your question requests. Obviously you can now amend
the
formula to represent any worksheet function you need.

Hope this helps,

Sean.

--
(please remember to click yes if replies you receive are helpful to
you)


"Craig" wrote:

I am a novice at macros and need a little help.

In Tab 1 I have a value in cell H35.

What I want to do is have the Macro go to Cell h38 in Tab 2 and have
that
cell put a formula to reference cell H35 on Tab 1. Then in Cell
I38:AD38
in
Tab 2 I want it to reference cell h38 of Tab 2.

I tried to record a Macro to do this and it keeps giving me errors. I
have
tried switching between relative reference and not and I still have an
error. So obviously I am doing something wrongs. Anyone have a code
that
will enable me to do this.

Thanks in advance.








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"