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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 09:47 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com