Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Issue creating a furmula in VBA, Please Help

I am trying to write a formula for a range that links data Sheet1(Cashflows
PBEY) to Sheet2EY Cashflows), the data in sheet1 is linked to a sheet I
copied from another workbook, the code below for some reason brings up like
an open file dialog with a title of "Update Values: PBEY" and is prompting me
to select a file to open??? I've used this code before and never sow this
below, can this be because the original data is on a sheet I copied from
anothr workbook? Please help me out, thanks.

Sheets(EYCF).Select
'With Sheets(EYCF)


TopAdd = Range(Cells(StartRow, eycfcusip), Cells(StartRow, eycfcusip)).Address
BottomAdd = Range(Cells(intNumOfTrDesc + HdrRow, eycfcusip),
Cells(intNumOfTrDesc + HdrRow, eycfcusip)).Address
Range(TopAdd, BottomAdd).name = "temp"
Range("temp").Formula = "=" & Sheets(CFPBEY).name & "!" & "RC"

I want sheet2!A1 to be linked to sheet1!A1 and all the way down.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Issue creating a furmula in VBA, Please Help

If you created that formula manually, you'd see that excel required that the
sheet name be surrounded by apostrophes. And if you're using the R1C1 reference
style, you may want to use .formular1c1, too:

Maybe it's as simple as:
Range("temp").FormulaR1C1 = "='" & Sheets(CFPBEY).name & "'!" & "RC"



mikeb wrote:

I am trying to write a formula for a range that links data Sheet1(Cashflows
PBEY) to Sheet2EY Cashflows), the data in sheet1 is linked to a sheet I
copied from another workbook, the code below for some reason brings up like
an open file dialog with a title of "Update Values: PBEY" and is prompting me
to select a file to open??? I've used this code before and never sow this
below, can this be because the original data is on a sheet I copied from
anothr workbook? Please help me out, thanks.

Sheets(EYCF).Select
'With Sheets(EYCF)

TopAdd = Range(Cells(StartRow, eycfcusip), Cells(StartRow, eycfcusip)).Address
BottomAdd = Range(Cells(intNumOfTrDesc + HdrRow, eycfcusip),
Cells(intNumOfTrDesc + HdrRow, eycfcusip)).Address
Range(TopAdd, BottomAdd).name = "temp"
Range("temp").Formula = "=" & Sheets(CFPBEY).name & "!" & "RC"

I want sheet2!A1 to be linked to sheet1!A1 and all the way down.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Issue creating a furmula in VBA, Please Help

thanks Dave, it worked, but it's weird because I have an almost identical
formula in another macro and it works, oh well!


"Dave Peterson" wrote:

If you created that formula manually, you'd see that excel required that the
sheet name be surrounded by apostrophes. And if you're using the R1C1 reference
style, you may want to use .formular1c1, too:

Maybe it's as simple as:
Range("temp").FormulaR1C1 = "='" & Sheets(CFPBEY).name & "'!" & "RC"



mikeb wrote:

I am trying to write a formula for a range that links data Sheet1(Cashflows
PBEY) to Sheet2EY Cashflows), the data in sheet1 is linked to a sheet I
copied from another workbook, the code below for some reason brings up like
an open file dialog with a title of "Update Values: PBEY" and is prompting me
to select a file to open??? I've used this code before and never sow this
below, can this be because the original data is on a sheet I copied from
anothr workbook? Please help me out, thanks.

Sheets(EYCF).Select
'With Sheets(EYCF)

TopAdd = Range(Cells(StartRow, eycfcusip), Cells(StartRow, eycfcusip)).Address
BottomAdd = Range(Cells(intNumOfTrDesc + HdrRow, eycfcusip),
Cells(intNumOfTrDesc + HdrRow, eycfcusip)).Address
Range(TopAdd, BottomAdd).name = "temp"
Range("temp").Formula = "=" & Sheets(CFPBEY).name & "!" & "RC"

I want sheet2!A1 to be linked to sheet1!A1 and all the way down.


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Issue creating a furmula in VBA, Please Help

It'll depend on the name of the worksheet. But if you always include the
apostrophes, your code will work--whether they're needed or not.

And excel/vba is pretty forgiving with the .formular1c1 v. .formula stuff. But
why let it forgive, just use the one that's appropriate (don't let excel guess
at what you want).

mikeb wrote:

thanks Dave, it worked, but it's weird because I have an almost identical
formula in another macro and it works, oh well!

"Dave Peterson" wrote:

If you created that formula manually, you'd see that excel required that the
sheet name be surrounded by apostrophes. And if you're using the R1C1 reference
style, you may want to use .formular1c1, too:

Maybe it's as simple as:
Range("temp").FormulaR1C1 = "='" & Sheets(CFPBEY).name & "'!" & "RC"



mikeb wrote:

I am trying to write a formula for a range that links data Sheet1(Cashflows
PBEY) to Sheet2EY Cashflows), the data in sheet1 is linked to a sheet I
copied from another workbook, the code below for some reason brings up like
an open file dialog with a title of "Update Values: PBEY" and is prompting me
to select a file to open??? I've used this code before and never sow this
below, can this be because the original data is on a sheet I copied from
anothr workbook? Please help me out, thanks.

Sheets(EYCF).Select
'With Sheets(EYCF)

TopAdd = Range(Cells(StartRow, eycfcusip), Cells(StartRow, eycfcusip)).Address
BottomAdd = Range(Cells(intNumOfTrDesc + HdrRow, eycfcusip),
Cells(intNumOfTrDesc + HdrRow, eycfcusip)).Address
Range(TopAdd, BottomAdd).name = "temp"
Range("temp").Formula = "=" & Sheets(CFPBEY).name & "!" & "RC"

I want sheet2!A1 to be linked to sheet1!A1 and all the way down.


--

Dave Peterson


--

Dave Peterson
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
Conditional Formating Furmula jockj215 Excel Discussion (Misc queries) 3 December 4th 09 12:36 PM
I want to get a furmula for get a percentage Bassil Excel Worksheet Functions 1 June 29th 08 06:08 PM
Desperately needing furmula help Fred Djinn Holstings Excel Discussion (Misc queries) 11 February 2nd 07 07:46 PM
OR Functions in a Conditional Formatting Furmula Kevin Rodriguez Excel Worksheet Functions 4 August 25th 06 10:10 AM
Furmula Dependent Cell References ned Excel Discussion (Misc queries) 2 May 4th 06 05:03 PM


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

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

About Us

"It's about Microsoft Excel"