ashperson95
New Member
- Joined
- May 16, 2014
- Messages
- 36
Okay, so I have a block of code that asks the user for several inputs and puts them into their corresponding cells in a table on the worksheet. Here's a look at it:
Now, the problem I'm having is when I go to check that the input the user gives is valid. I'm only on the first one, the fixtures variable. Everything was working fine, but when I added in the code that's below and tried to run it, I received a compile error that says "Next without For". I'm not sure where I need to add in the For.
Any help would be appreciated!
Code:
locationNum = 1
For Each InfoInput In Range("Table2[Location]")
InfoInput.Value = InputBox("Name of location " & locationNum, "Name of Location")
fixtures = InputBox("How many fixtures does location " & locationNum & " have?")
InfoInput.Offset(, 1).Value = fixtures
LightTypes.Show
InfoInput.Offset(, 2).Value = LightTypes.ComboBox1.Value
hoursDay = InputBox("How many hours a day do the fixtures in location " & locationNum & " run?")
InfoInput.Offset(, 3).Value = hoursDay
locationNum = locationNum + 1
Next InfoInput
Now, the problem I'm having is when I go to check that the input the user gives is valid. I'm only on the first one, the fixtures variable. Everything was working fine, but when I added in the code that's below and tried to run it, I received a compile error that says "Next without For". I'm not sure where I need to add in the For.
Code:
fixtures = InputBox("How many fixtures does location " & locationNum & " have?")
If Not IsNumeric(fixtures) Then
Do Until IsNumeric(fixtures)
fixtures = InputBox("Sorry, that's not a valid entry. How many fixtures does location " & locationNum & " have?")
Loop
Any help would be appreciated!
Last edited: