Inputboxes VBA

Joseph111

New Member
Joined
Jan 10, 2021
Messages
19
Office Version
  1. 2016
Platform
  1. Windows
Hello all

I will be thankful to help me.

I would like to pop inputboxes, when I open specific worksheet.

My purpose is to pop the first one when I open the sheed, after that to ask me "Enter the code" input code, when I enter the code to pop another input box with 10/11 rows ( details for the code).

And I would like to have the posibility to input all data for this code in all rows, and after click OK all the data to enter in each specific cell according to the information.

For example:

A1 A2 A3 A4
Code Name Color Size .......................
111

In the first box to enter 111, after that another box to ask me input Name,color,size and etc. When I click OK these data to enter in A2(name), A3(color), A4(size)

Is the VBA code is complicated?

Thank you in advance!
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Place this code in your sheet module for it to activate when you open the sheet.
I wrote it to prevent overwriting if the cells contain data.

VBA Code:
Private Sub Worksheet_Activate()
If [A1].Value = "" Then
    [A1].Value = InputBox("Enter Code", "Code")
End If
If [B1].Value = "" Then
    [B1].Value = InputBox("Enter Name", "Name")
End If
If [C1].Value = "" Then
    [C1].Value = InputBox("Enter Color", "Color")
End If
If [D1].Value = "" Then
    [D1].Value = InputBox("Enter Size", "Size")
End If
End Sub
 
Upvote 0
Hello Thanks for the replu. It works

But my idea is not exactly this, If input the code in the first inputbox the system automaticaly to find the row.After that to ask us for all the data.

I mean for example if we have 6 rows and 6 columns in the first column are the codes.

The rest column are empty.

A B C D E F
1 code1
2 code2
3 code3
4 code4
6 code5

In the first inputbox to input the code(for example: code3), after that another inputbox to ask us for all the data and they will enter in B3, C3, D3, E3, F3

And according this idea if we have 1000 codes we will have the posibility to input the data for all of them without searching every one.

Thanks!
 
Upvote 0
This code will work for an indefinite number of rows and will ask for the value showing the cell that will populate. Let me know if you have questions.

VBA Code:
Private Sub Worksheet_Activate()
Dim i, lastrow As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lastrow
If Cells(i, 1).Value = "" Then
    Cells(i, 1).Value = InputBox("Enter Code for cell " & Cells(i, 1).Address, "Code")
End If
If Cells(i, 2).Value = "" Then
    Cells(i, 2).Value = InputBox("Enter Name for cell " & Cells(i, 2).Address, "Name")
End If
If Cells(i, 3).Value = "" Then
    Cells(i, 3).Value = InputBox("Enter Color for cell " & Cells(i, 3).Address, "Color")
End If
If Cells(i, 4).Value = "" Then
    Cells(i, 4).Value = InputBox("Enter Size for cell " & Cells(i, 4).Address, "Size")
End If
Next i
End Sub
 
Upvote 0
This code will work for an indefinite number of rows and will ask for the value showing the cell that will populate. Let me know if you have questions.

VBA Code:
Private Sub Worksheet_Activate()
Dim i, lastrow As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lastrow
If Cells(i, 1).Value = "" Then
    Cells(i, 1).Value = InputBox("Enter Code for cell " & Cells(i, 1).Address, "Code")
End If
If Cells(i, 2).Value = "" Then
    Cells(i, 2).Value = InputBox("Enter Name for cell " & Cells(i, 2).Address, "Name")
End If
If Cells(i, 3).Value = "" Then
    Cells(i, 3).Value = InputBox("Enter Color for cell " & Cells(i, 3).Address, "Color")
End If
If Cells(i, 4).Value = "" Then
    Cells(i, 4).Value = InputBox("Enter Size for cell " & Cells(i, 4).Address, "Size")
End If
Next i
End Sub
ManiacB Thank you for your help

My idea is similar but i didn`t explane very well:

I mean that I have the codes:
1. When the worksheet is active to appear the message "Input code"
1a. When I input the code.The system automatically find the row with this code ( for example code333)
2.After that to pop up another message "input name"
2a.When the name is written into the box this value to enter in B3
3.After that another to pop up another box "Input color"
3a. This value to be saved in cell C3
..................................
and etc to the last parameter for the code for example K3



A B C D
(code) (name) (color) (size)
code111
code222
code333
code444

I hope that my explanation is clear, Thank you in advance
 
Upvote 0
Try this

VBA Code:
Private Sub Worksheet_Activate()
Dim i, lastrow, code, rw As Long

lastrow = Cells(Rows.Count, 1).End(xlUp).Row
code = InputBox("Which code are you searching for ", "Code")
i = Range("A:A").Find(code).Row

If Cells(i, 2).Value = "" Then
    Cells(i, 2).Value = InputBox("Enter Name for code " & code, "Name")
End If
If Cells(i, 3).Value = "" Then
    Cells(i, 3).Value = InputBox("Enter Color for code " & code, "Color")
End If
If Cells(i, 4).Value = "" Then
    Cells(i, 4).Value = InputBox("Enter Size for code " & code, "Size")
End If

End Sub
 
Upvote 0
Try this

VBA Code:
Private Sub Worksheet_Activate()
Dim i, lastrow, code, rw As Long

lastrow = Cells(Rows.Count, 1).End(xlUp).Row
code = InputBox("Which code are you searching for ", "Code")
i = Range("A:A").Find(code).Row

If Cells(i, 2).Value = "" Then
    Cells(i, 2).Value = InputBox("Enter Name for code " & code, "Name")
End If
If Cells(i, 3).Value = "" Then
    Cells(i, 3).Value = InputBox("Enter Color for code " & code, "Color")
End If
If Cells(i, 4).Value = "" Then
    Cells(i, 4).Value = InputBox("Enter Size for code " & code, "Size")
End If

End Sub
Hello
Thanks it works very well, as I want thanks for your help

Please for something else, How can I coppy the information from another sheet while some of the boxes is active? Because it`s not possible.
 
Upvote 0

Forum statistics

Threads
1,215,062
Messages
6,122,923
Members
449,094
Latest member
teemeren

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