Userform writing to the next column?

saprater

New Member
Joined
Oct 25, 2017
Messages
5
Hello all, Brand new user and new to Excel Coding. I am working on a userform that asks for specific inputs. Depending on what those are, we could have the response to the Questions, we could have the need for between, 3 to 6 more Fields for entry.

Example, if I state in my user form I want a file server, I will need to add 5 extra drives and configs.
If I state in my user form I want a app server, I will only need to add 2 extra drives to the configs.

So my question is.

If I want to dynamically add the data back to the work sheet if there is a drive that is selected, how do I select the next free column?

I currently use static placement with my add button, here is the code I am using.

The next values would be txtdrive1,2,3,4,5 etc, but if nothing used for Drive 3,4,5 I want my next cell to populate next to the drive2 column.

Hope this is making sense and appreciate any direction you can point me.

Private Sub cmdaddserver_Click()
Range("A1").Select
'if all the above are false (OK) then carry on.
'check to see the next available blank row start at cell A2...
Do Until ActiveCell.Value = Empty
ActiveCell.Offset(1, 0).Select 'move down 1 row
Loop
'Populate the new data values into the 'Data' worksheet.
ActiveCell.Value = i 'Next ID number
ActiveCell.Offset(0, 1).Value = Me.ComboBox1.Value
ActiveCell.Offset(0, 7).Value = Me.ComboBox2.Value
ActiveCell.Offset(0, 0).Value = Me.txtservername.Value
ActiveCell.Offset(0, 2).Value = Me.ComboBox3.Value
ActiveCell.Offset(0, 3).Value = Me.txtsockets.Value
ActiveCell.Offset(0, 4).Value = Me.txtcores.Value
ActiveCell.Offset(0, 5).Value = Me.txtmemory.Value
ActiveCell.Offset(0, 6).Value = Me.txtnetwork.Value


'Clear the Data
Me.ComboBox1.Value = ""
Me.ComboBox2.Value = ""
Me.txtservername.Value = ""
Me.ComboBox3.Value = ""
Me.txtsockets.Value = ""
Me.txtcores.Value = ""
Me.txtmemory = ""
Me.txtnetwork = ""
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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