Message Box help vba

caritx

New Member
Joined
Dec 1, 2009
Messages
34
I have this code which works great but in the text I also want it to display the line count for column A and the sum of AZ

Sub test()
'
' Batch test
'
Dim addbatch As String

addbatch = InputBox("Batch")

Range("BC1").Select
ActiveCell.Offset(1, 0).FormulaR1C1 = addbatch


'
End Sub

I really appreciate any help you can give! Thanks
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Can you give an example of what would be entered in the input box? I'm not sure I see where we get from there to a line count or a sum.

ξ
 
Upvote 0
I have a message box that says this. I would like it to be the text over the imput box:

MsgBox ("Gifts" & " " & Range("B1")) & vbCrLf & "Sum" & " " & Range("B2") & vbCrLf & "Batch Name:"<o:p></o:p>


Thanks!
 
Last edited:
Upvote 0
Not sure, is this closer to what you need:

Code:
Dim msg As String
Dim addbatch As String

msg = "Gifts" & " "
msg = msg & WorksheetFunction.CountA(Range("A2:A65536")) '//Count of Column A, starting at row 2
msg = msg & vbCrLf & "Sum" & " "
msg = msg & WorksheetFunction.Sum.Range("AZ2:AZ65536") '//Sum of Column AZ, starting at row 2
msg = msg & vbCrLf & "Batch Name:"

addbatch = InputBox(msg, "Batch")

Range("BC1").Offset(1, 0).FormulaR1C1 = addbatch
 
Upvote 0
Currently I have two boxes and I want to combine them. I want the gift and sum info above the field where they can enter the batch data.
screenshot.jpg
 
Upvote 0
Fixed the compile error, I think. What I am unsure of is if I am summing, counting properly. Check my comments (in green) below - are they right for the cells to add up or count up? Note that we can format the numbers later.

Code:
Dim msg As String
Dim addbatch As String

msg = "Gifts" & " "
msg = msg & WorksheetFunction.CountA(Range("A2:A65536")) [COLOR="SeaGreen"]'//Count of Column A, starting at row 2[/COLOR]
msg = msg & vbCrLf & "Sum" & " "
msg = msg & WorksheetFunction.Sum(Range("AZ2:AZ65536")) [COLOR="seagreen"]'//Sum of Column AZ, starting at row 2[/COLOR]
msg = msg & vbCrLf & "Batch Name:"

addbatch = InputBox(msg, "Batch")

Range("BC1").Offset(1, 0).FormulaR1C1 = addbatch
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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