VBA to sum cells with text

Shadkng

Active Member
Joined
Oct 11, 2018
Messages
365
Hi, I am using the below line of code to build a filename based on the values in various cells. I would like to sum the value of cells B10 and B11, however there is a formula in B11 and when there is no value I am getting an error. I know that using SUM in a regular formula negates the #VALUE error when adding cells that have text. So my question is there a way to use the SUM function to add B10 & B11 in this line to avoid the error? Thanks for the help.

VBA Code:
fileSaveName = "FRIEDLAND QUOTE " & [B7] & " " & "JOB " & [B8] & " " & [A30] & " " & [AB26] & " " & [COLOR=rgb(184, 49, 47)][B][B10+B11][/B][/COLOR] & " PCS" & " " & Format(Date, "mmddyy")
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hi Shadkng,

Assuming you're using Excel 2007 or higher just wrap the current formula in cell B11 with the IFERROR function to return zero if it errors out.

Robert
 
Upvote 0
If you use the Sum function instead of "+" it will treat the text as zero.
Rich (BB code):
fileSaveName = "FRIEDLAND QUOTE " & [B7] & " " & "JOB " & [B8] & " " & [A30] & " " & [AB26] & " " & _
                    Application.Sum([B10,B11]) & " PCS" & " " & Format(Date, "mmddyy")
 
Upvote 0
Solution
If you use the Sum function instead of "+" it will treat the text as zero.
Rich (BB code):
fileSaveName = "FRIEDLAND QUOTE " & [B7] & " " & "JOB " & [B8] & " " & [A30] & " " & [AB26] & " " & _
                    Application.Sum([B10,B11]) & " PCS" & " " & Format(Date, "mmddyy")
Hi Alex, sorry for the delay in replying. Your solution worked great! Much appreciated.
Thanks
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,395
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top