Excel/VBA input box


Hi Tom,

I have a few macro's I use on a regular basis, some of which you helped me with in the past (thanks very much). I want to tie a couple of these together now so that I can run them in one step. I think I can tie them together ok. Where I am stuck is that one macro has an input box. The info that goes into this box is in the filtered spreadsheet I am working with. It will always be the contents of the last cell in column n. Because it is a filtered report, the row# always changes. I would like to put that cell content into the input box and then the macro can continue. That macro itself just formats a footer. The content of N(row#)is what goes into the footer.

Hope that is clear. I imagine it must be hard to understand what people are asking you sometimes.

Thanks for your help.



You can't put a value in an inputbox and click the button - at least it wouldn't make sense.

if you have a code snippet like this

ans = InputBox("Enter something")

s = "My string " & ans & " more of my string"

then you don't want to show the inputbox.  You just want to pick up your data from the column and use that as if it was from the input of the inputbox.

if bFlag then
 ans = InputBox("Enter something")
 ans = cells(rows.count, "N").End(xlup).Value
end if

s = "My string " & ans & " more of my string"

bFlag would be a Boolean variable that is set by the code and tells this routine whether to show the inputbox or just get the value.  

that is about the best I can tell you based on the limited information you have provided.

Tom Ogilvy

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Tom Ogilvy


Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]


Extensive experience.

Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2017 About.com. All rights reserved.