Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VBA Range.Formula

Hello,

I have a problem with below VBA code to read the cells formula into VBA

Dim objSheet As Excel.Worksheet
Set objSheet = ThisWorkbook.Sheets("Master")
Dim varSheetData As Variant
varSheetData = objSheet.Range("A9:FB820").Formula

when above line is execute, a error 1004 Application-defined or
object-defined error was occur

but if the code change to read cells value
varSheetData = objSheet.Range("A9:FB820").Value
its ok and give me a array contain all the data...

is there anything I was missing or it just not supported??

Thanks, King.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default VBA Range.Formula

Probably too complicated to program the return of the formulas, since the
precedents and dependents could also be involved. However, it will return a
single cell formula.


"King" wrote in message
...
Hello,

I have a problem with below VBA code to read the cells formula into VBA

Dim objSheet As Excel.Worksheet
Set objSheet = ThisWorkbook.Sheets("Master")
Dim varSheetData As Variant
varSheetData = objSheet.Range("A9:FB820").Formula

when above line is execute, a error 1004 Application-defined or
object-defined error was occur

but if the code change to read cells value
varSheetData = objSheet.Range("A9:FB820").Value
its ok and give me a array contain all the data...

is there anything I was missing or it just not supported??

Thanks, King.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default VBA Range.Formula

Reading into a variant array doesn't work with .Formula

Tim

"King" wrote in message
...
Hello,

I have a problem with below VBA code to read the cells formula into VBA

Dim objSheet As Excel.Worksheet
Set objSheet = ThisWorkbook.Sheets("Master")
Dim varSheetData As Variant
varSheetData = objSheet.Range("A9:FB820").Formula

when above line is execute, a error 1004 Application-defined or
object-defined error was occur

but if the code change to read cells value
varSheetData = objSheet.Range("A9:FB820").Value
its ok and give me a array contain all the data...

is there anything I was missing or it just not supported??

Thanks, King.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VBA Range.Formula

Thanks, Tim,

I will try change the code to read the cells with formula one by one...

King

"Tim Williams" wrote in message
...
Reading into a variant array doesn't work with .Formula

Tim

"King" wrote in message
...
Hello,

I have a problem with below VBA code to read the cells formula into VBA

Dim objSheet As Excel.Worksheet
Set objSheet = ThisWorkbook.Sheets("Master")
Dim varSheetData As Variant
varSheetData = objSheet.Range("A9:FB820").Formula

when above line is execute, a error 1004 Application-defined or
object-defined error was occur

but if the code change to read cells value
varSheetData = objSheet.Range("A9:FB820").Value
its ok and give me a array contain all the data...

is there anything I was missing or it just not supported??

Thanks, King.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VBA Range.Formula

Thanks, Tim,

I will try change the code to read the cells with formula one by one...

King

"Tim Williams" wrote in message
...
Reading into a variant array doesn't work with .Formula

Tim

"King" wrote in message
...
Hello,

I have a problem with below VBA code to read the cells formula into VBA

Dim objSheet As Excel.Worksheet
Set objSheet = ThisWorkbook.Sheets("Master")
Dim varSheetData As Variant
varSheetData = objSheet.Range("A9:FB820").Formula

when above line is execute, a error 1004 Application-defined or
object-defined error was occur

but if the code change to read cells value
varSheetData = objSheet.Range("A9:FB820").Value
its ok and give me a array contain all the data...

is there anything I was missing or it just not supported??

Thanks, King.







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default VBA Range.Formula

Hmm, it works for me.

Dim varSheetData As Variant
varSheetData = Range("A9:FB820").Formula

Just tested it.

In the immediate window:
?varSheetData(812,158)
=ADDRESS(ROW(),COLUMN(),4)

As an alternative try FormulaR1C1. Then convert back using:

application.ConvertFormula(varSheetData(812,158) ,xlR1C1,xlA1)

--
Regards,
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility


"King" wrote in message
...
Hello,

I have a problem with below VBA code to read the cells formula into VBA

Dim objSheet As Excel.Worksheet
Set objSheet = ThisWorkbook.Sheets("Master")
Dim varSheetData As Variant
varSheetData = objSheet.Range("A9:FB820").Formula

when above line is execute, a error 1004 Application-defined or
object-defined error was occur

but if the code change to read cells value
varSheetData = objSheet.Range("A9:FB820").Value
its ok and give me a array contain all the data...

is there anything I was missing or it just not supported??

Thanks, King.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VBA Range.Formula

Ohh..........

I got the problem, its because the worksheet that I want to read the formula
is protected,
I can now read the formula by cancel the protection first and enable back
after read.

King

"Tim Zych" <tzych@nospam at earthlink dot net wrote in message
...
Hmm, it works for me.

Dim varSheetData As Variant
varSheetData = Range("A9:FB820").Formula

Just tested it.

In the immediate window:
?varSheetData(812,158)
=ADDRESS(ROW(),COLUMN(),4)

As an alternative try FormulaR1C1. Then convert back using:

application.ConvertFormula(varSheetData(812,158) ,xlR1C1,xlA1)

--
Regards,
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility


"King" wrote in message
...
Hello,

I have a problem with below VBA code to read the cells formula into VBA

Dim objSheet As Excel.Worksheet
Set objSheet = ThisWorkbook.Sheets("Master")
Dim varSheetData As Variant
varSheetData = objSheet.Range("A9:FB820").Formula

when above line is execute, a error 1004 Application-defined or
object-defined error was occur

but if the code change to read cells value
varSheetData = objSheet.Range("A9:FB820").Value
its ok and give me a array contain all the data...

is there anything I was missing or it just not supported??

Thanks, King.





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VBA Range.Formula

Ohh..........

I got the problem, its because the worksheet that I want to read the formula
is protected,
I can now read the formula by cancel the protection first and enable back
after read.

King

"Tim Zych" <tzych@nospam at earthlink dot net wrote in message
...
Hmm, it works for me.

Dim varSheetData As Variant
varSheetData = Range("A9:FB820").Formula

Just tested it.

In the immediate window:
?varSheetData(812,158)
=ADDRESS(ROW(),COLUMN(),4)

As an alternative try FormulaR1C1. Then convert back using:

application.ConvertFormula(varSheetData(812,158) ,xlR1C1,xlA1)

--
Regards,
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility


"King" wrote in message
...
Hello,

I have a problem with below VBA code to read the cells formula into VBA

Dim objSheet As Excel.Worksheet
Set objSheet = ThisWorkbook.Sheets("Master")
Dim varSheetData As Variant
varSheetData = objSheet.Range("A9:FB820").Formula

when above line is execute, a error 1004 Application-defined or
object-defined error was occur

but if the code change to read cells value
varSheetData = objSheet.Range("A9:FB820").Value
its ok and give me a array contain all the data...

is there anything I was missing or it just not supported??

Thanks, King.





  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default VBA Range.Formula

I guess I should test before posting...

Tim

"Tim Zych" <tzych@nospam at earthlink dot net wrote in message
...
Hmm, it works for me.

Dim varSheetData As Variant
varSheetData = Range("A9:FB820").Formula

Just tested it.

In the immediate window:
?varSheetData(812,158)
=ADDRESS(ROW(),COLUMN(),4)

As an alternative try FormulaR1C1. Then convert back using:

application.ConvertFormula(varSheetData(812,158) ,xlR1C1,xlA1)

--
Regards,
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility


"King" wrote in message
...
Hello,

I have a problem with below VBA code to read the cells formula into VBA

Dim objSheet As Excel.Worksheet
Set objSheet = ThisWorkbook.Sheets("Master")
Dim varSheetData As Variant
varSheetData = objSheet.Range("A9:FB820").Formula

when above line is execute, a error 1004 Application-defined or
object-defined error was occur

but if the code change to read cells value
varSheetData = objSheet.Range("A9:FB820").Value
its ok and give me a array contain all the data...

is there anything I was missing or it just not supported??

Thanks, King.





  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default VBA Range.Formula

I guess I should test before posting...

Tim

"Tim Zych" <tzych@nospam at earthlink dot net wrote in message
...
Hmm, it works for me.

Dim varSheetData As Variant
varSheetData = Range("A9:FB820").Formula

Just tested it.

In the immediate window:
?varSheetData(812,158)
=ADDRESS(ROW(),COLUMN(),4)

As an alternative try FormulaR1C1. Then convert back using:

application.ConvertFormula(varSheetData(812,158) ,xlR1C1,xlA1)

--
Regards,
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility


"King" wrote in message
...
Hello,

I have a problem with below VBA code to read the cells formula into VBA

Dim objSheet As Excel.Worksheet
Set objSheet = ThisWorkbook.Sheets("Master")
Dim varSheetData As Variant
varSheetData = objSheet.Range("A9:FB820").Formula

when above line is execute, a error 1004 Application-defined or
object-defined error was occur

but if the code change to read cells value
varSheetData = objSheet.Range("A9:FB820").Value
its ok and give me a array contain all the data...

is there anything I was missing or it just not supported??

Thanks, King.





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
How do I enter formula sum(range+range)*0.15 sumif(range=3) tkw Excel Discussion (Misc queries) 2 October 1st 09 09:17 PM
conditional formula: sum a range if text present in another range NeedAdvice777 Excel Discussion (Misc queries) 10 August 29th 06 04:51 PM
formula to sort a range so that it matches the exact rows of a column that is outside that range? steveo Excel Discussion (Misc queries) 1 June 18th 06 02:05 AM
Macro to input formula in range based on another range Peter Atherton Excel Programming 0 October 9th 03 12:47 AM
Range.Formula and Range question using Excel Automation [email protected] Excel Programming 0 September 19th 03 04:53 AM


All times are GMT +1. The time now is 04:01 PM.

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"