Input box code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello

I have a spreadsheet with a blank column waiting to be populated by the user
- let's call it 'category A'.
At let's say every 5th cell going down the column I need an input box to pop
up and ask the user if any of the value he is inputting is 'category B'.
The value entered (even if it is a zero) should then be put in the cell
immediately to the right of the original cell.

Can anyone help please?
 
Take a look at using the WOrksheet_selectionchange macro.

Right click on the worksheet tab that you want to add the macro to and
select view code.

You should see a pulldown menu that reads GENERAL. Change it to Worksheet.

Copy this code in

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row Mod 5 <> 0 Or Target.Column <> 1 Then Exit Sub

CatB = InputBox("Enter Category B value", CatB)
Target.Offset(0, 1).Value = CatB


End Sub

This will give you an input box for every 5th row (5, 10, 15, etc) and
column 1. If you want a different one, modify the IF statement.

Good luck.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top