ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Input box code (https://www.excelbanter.com/excel-programming/386847-input-box-code.html)

Les

Input box code
 
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?




Barb Reinhardt

Input box code
 
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.

"Les" wrote:

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?





All times are GMT +1. The time now is 05:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com