Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
SUMIF CODE
What is wrong with this statement it igves "expected end of statement" error
msg. sub abc() pos=15 Range(Cells(3, 2), Cells(pos, 2)) = "=SUMIF(A2:A5,"10")" end sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
SUMIF CODE
If you dont want the 10 in quotes then Code: -------------------- Range(Cells(3, 2), Cells(pos, 2)).Value = "=SUMIF(A2:A5,10)" -------------------- however if you do then Code: -------------------- Range(Cells(3, 2), Cells(pos, 2)).Value = "=SUMIF(A2:A5," & Chr(34) & "10" & Chr(34) & ")" -------------------- -- Simon Lloyd Regards, Simon Lloyd 'The Code Cage' (http://www.thecodecage.com) ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1 View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=36902 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
SUMIF CODE
Double up the double quotes in strings in your VBA code:
Range(Cells(3, 2), Cells(pos, 2)) = "=SUMIF(A2:A5,""10"")" ezil wrote: What is wrong with this statement it igves "expected end of statement" error msg. sub abc() pos=15 Range(Cells(3, 2), Cells(pos, 2)) = "=SUMIF(A2:A5,"10")" end sub -- Dave Peterson |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
SUMIF CODE
Yes Dave, a much smarter approach! -- Simon Lloyd Regards, Simon Lloyd 'The Code Cage' (http://www.thecodecage.com) ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1 View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=36902 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
SumIf Calculation in Code Problem | Excel Programming | |||
change SUMIF formula into a vb code | Excel Discussion (Misc queries) | |||
How to simplfy If & Sumif Code | Excel Discussion (Misc queries) | |||
Usage of SUMIF formula in the VBA code | Excel Programming | |||
Sumif in VB Code | Excel Programming |