Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Pam Pam is offline
external usenet poster
 
Posts: 128
Default Formula, quotes, and variable

Can you help me with this code. If I type it in the cell, it works. But I
can't get the VBA code to work. I get 1004 error. It has to do with the
"Month" variable. It won't accept the text "Mo 1*" in the formula in VBA

Sub FillEarnedvalue()
Dim MonthNo As Integer
Dim Month As String


MonthNo = 1
Month = "Mo " & MonthNo & "*"

Sheets("Status").Range("k8").Select
Do While MonthNo <= Sheets("Estimate").Range("O2")
Month = "Mo " & MonthNo & "*"

ActiveCell.FormulaR1C1 = _
"=(SUMIFS(Estimate!R[31]C23:R[31]C76,Estimate!R5C23:R5C76,""*Est
Hrs"",Estimate!R5C23:R5C76," & Month & "))+RC[-1]"
ActiveCell.Offset(0, 1).Select

MonthNo = MonthNo + 1
Loop
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Formula, quotes, and variable

Month is a name used by the system, you cannot adapt it, only use it, use
strMonth or MonthName or something like that instead.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Pam" wrote:

Can you help me with this code. If I type it in the cell, it works. But I
can't get the VBA code to work. I get 1004 error. It has to do with the
"Month" variable. It won't accept the text "Mo 1*" in the formula in VBA

Sub FillEarnedvalue()
Dim MonthNo As Integer
Dim Month As String


MonthNo = 1
Month = "Mo " & MonthNo & "*"

Sheets("Status").Range("k8").Select
Do While MonthNo <= Sheets("Estimate").Range("O2")
Month = "Mo " & MonthNo & "*"

ActiveCell.FormulaR1C1 = _
"=(SUMIFS(Estimate!R[31]C23:R[31]C76,Estimate!R5C23:R5C76,""*Est
Hrs"",Estimate!R5C23:R5C76," & Month & "))+RC[-1]"
ActiveCell.Offset(0, 1).Select

MonthNo = MonthNo + 1
Loop
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
Pam Pam is offline
external usenet poster
 
Posts: 128
Default Formula, quotes, and variable

Thank you. That is very good to know; however, I still get the same error.

"John Bundy" wrote:

Month is a name used by the system, you cannot adapt it, only use it, use
strMonth or MonthName or something like that instead.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Pam" wrote:

Can you help me with this code. If I type it in the cell, it works. But I
can't get the VBA code to work. I get 1004 error. It has to do with the
"Month" variable. It won't accept the text "Mo 1*" in the formula in VBA

Sub FillEarnedvalue()
Dim MonthNo As Integer
Dim Month As String


MonthNo = 1
Month = "Mo " & MonthNo & "*"

Sheets("Status").Range("k8").Select
Do While MonthNo <= Sheets("Estimate").Range("O2")
Month = "Mo " & MonthNo & "*"

ActiveCell.FormulaR1C1 = _
"=(SUMIFS(Estimate!R[31]C23:R[31]C76,Estimate!R5C23:R5C76,""*Est
Hrs"",Estimate!R5C23:R5C76," & Month & "))+RC[-1]"
ActiveCell.Offset(0, 1).Select

MonthNo = MonthNo + 1
Loop
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
Pam Pam is offline
external usenet poster
 
Posts: 128
Default Formula, quotes, and variable

I finally found some help at
http://www.microsoft.com/technet/scr...6/hey0713.mspx. I had to modify my formula to:

ActiveCell.FormulaR1C1 = _
"=(SUMIFS(Estimate!R[31]C23:R[31]C76,Estimate!R5C23:R5C76,""*Est
Hrs"",Estimate!R5C23:R5C76," & Chr(34) & "Mo " & MonthNo & "*" & Chr(34) &
"))+RC[-1]"

"Pam" wrote:

Thank you. That is very good to know; however, I still get the same error.

"John Bundy" wrote:

Month is a name used by the system, you cannot adapt it, only use it, use
strMonth or MonthName or something like that instead.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Pam" wrote:

Can you help me with this code. If I type it in the cell, it works. But I
can't get the VBA code to work. I get 1004 error. It has to do with the
"Month" variable. It won't accept the text "Mo 1*" in the formula in VBA

Sub FillEarnedvalue()
Dim MonthNo As Integer
Dim Month As String


MonthNo = 1
Month = "Mo " & MonthNo & "*"

Sheets("Status").Range("k8").Select
Do While MonthNo <= Sheets("Estimate").Range("O2")
Month = "Mo " & MonthNo & "*"

ActiveCell.FormulaR1C1 = _
"=(SUMIFS(Estimate!R[31]C23:R[31]C76,Estimate!R5C23:R5C76,""*Est
Hrs"",Estimate!R5C23:R5C76," & Month & "))+RC[-1]"
ActiveCell.Offset(0, 1).Select

MonthNo = MonthNo + 1
Loop
End Sub

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
change straight quotes to curly quotes callico Excel Discussion (Misc queries) 2 June 22nd 07 10:23 PM
Quotes in .formula calcs Paulymon Excel Programming 1 February 28th 06 11:14 PM
Adding quotes to the ends of a string variable Torben Laursen Excel Programming 2 November 13th 04 11:37 AM
Quotes in formula Kevin Excel Programming 1 December 2nd 03 05:53 PM
Formula with quotes and ampersand Neil[_11_] Excel Programming 3 November 10th 03 07:49 AM


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