Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 155
Default Problem Applying Formula to cell

Hi

I have a problem a with macro I have recorded/written.
The macro applies a formula to a range of cells which references values in a
column in a separate worksheet and returns cell contents from this worksheet
then deletes blank rows.

The macro runs as expected when the formula has been entered manually in the
starting cell but as soon as i try to apply the formula as part of the macro
(commented out second line) it returns error code 1004.




Range("A3").Select
' ActiveCell.FormulaR1C1 = "=IF('Raw data'!$I1-25 =TODAY(),'Raw
data'!A1,"")"
Selection.AutoFill Destination:=Range("A3:N3"), Type:=xlFillDefault
Range("A3:N3").Select
Selection.AutoFill Destination:=Range("A3:N65000"), Type:=xlFillDefault
Range("A3:N65000").Select

ActiveSheet.UsedRange.Select
X = ActiveSheet.UsedRange.Columns.Count
Selection.AutoFilter
For i = 1 To X
Selection.AutoFilter Field:=i, Criteria1:="="
Next
X = ActiveSheet.UsedRange.Count
Range("A2:G" & X & "").Delete
ActiveSheet.AutoFilterMode = False

Range("i3:i65000").Select
Range("i3:i65000").Activate
Selection.NumberFormat = "m/d/yyyy"
Range("A1").Select


End Sub




Any help would be much appreciated

Graham
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Problem Applying Formula to cell

The " will get you every time BUT Chr(34) = " so....

ActiveCell.Formula = _
"=IF('Raw data'!$I1-25 =TODAY(),'Raw data'!A1," & _
Chr(34) & Chr(34) & ")"

--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"Graham" wrote:

Hi

I have a problem a with macro I have recorded/written.
The macro applies a formula to a range of cells which references values in a
column in a separate worksheet and returns cell contents from this worksheet
then deletes blank rows.

The macro runs as expected when the formula has been entered manually in the
starting cell but as soon as i try to apply the formula as part of the macro
(commented out second line) it returns error code 1004.




Range("A3").Select
' ActiveCell.FormulaR1C1 = "=IF('Raw data'!$I1-25 =TODAY(),'Raw
data'!A1,"")"
Selection.AutoFill Destination:=Range("A3:N3"), Type:=xlFillDefault
Range("A3:N3").Select
Selection.AutoFill Destination:=Range("A3:N65000"), Type:=xlFillDefault
Range("A3:N65000").Select

ActiveSheet.UsedRange.Select
X = ActiveSheet.UsedRange.Columns.Count
Selection.AutoFilter
For i = 1 To X
Selection.AutoFilter Field:=i, Criteria1:="="
Next
X = ActiveSheet.UsedRange.Count
Range("A2:G" & X & "").Delete
ActiveSheet.AutoFilterMode = False

Range("i3:i65000").Select
Range("i3:i65000").Activate
Selection.NumberFormat = "m/d/yyyy"
Range("A1").Select


End Sub




Any help would be much appreciated

Graham

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 155
Default Problem Applying Formula to cell

Cheers Gary
Works like a charm, thanks for your help

Graham

"Gary Brown" wrote:

The " will get you every time BUT Chr(34) = " so....

ActiveCell.Formula = _
"=IF('Raw data'!$I1-25 =TODAY(),'Raw data'!A1," & _
Chr(34) & Chr(34) & ")"

--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"Graham" wrote:

Hi

I have a problem a with macro I have recorded/written.
The macro applies a formula to a range of cells which references values in a
column in a separate worksheet and returns cell contents from this worksheet
then deletes blank rows.

The macro runs as expected when the formula has been entered manually in the
starting cell but as soon as i try to apply the formula as part of the macro
(commented out second line) it returns error code 1004.




Range("A3").Select
' ActiveCell.FormulaR1C1 = "=IF('Raw data'!$I1-25 =TODAY(),'Raw
data'!A1,"")"
Selection.AutoFill Destination:=Range("A3:N3"), Type:=xlFillDefault
Range("A3:N3").Select
Selection.AutoFill Destination:=Range("A3:N65000"), Type:=xlFillDefault
Range("A3:N65000").Select

ActiveSheet.UsedRange.Select
X = ActiveSheet.UsedRange.Columns.Count
Selection.AutoFilter
For i = 1 To X
Selection.AutoFilter Field:=i, Criteria1:="="
Next
X = ActiveSheet.UsedRange.Count
Range("A2:G" & X & "").Delete
ActiveSheet.AutoFilterMode = False

Range("i3:i65000").Select
Range("i3:i65000").Activate
Selection.NumberFormat = "m/d/yyyy"
Range("A1").Select


End Sub




Any help would be much appreciated

Graham

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
help for applying formula Raan Excel Programming 2 November 18th 07 01:05 PM
Applying a cell format within a Formula BRMeter Excel Discussion (Misc queries) 2 August 21st 07 03:46 PM
Applying Formula Based on Cell Contents vilja Excel Programming 5 November 8th 06 05:30 PM
applying formula Pat N. Excel Discussion (Misc queries) 1 April 25th 06 08:47 PM
Applying formula when a particular value occurs smurray444[_7_] Excel Programming 1 February 4th 06 02:01 AM


All times are GMT +1. The time now is 09:25 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"