ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save userform values in excel sheet (https://www.excelbanter.com/excel-programming/392499-save-userform-values-excel-sheet.html)

Hendrik[_2_]

Save userform values in excel sheet
 
HI,

I'm new to the userforms. I've created on with a combobox and a textbox. In
the same workbook I have a sheet called "Results". When a user clicks "OK" I
want the selected values to populate the results worksheet. It works fine
with the code below:

Worksheets("Results").Range("$B2") = UserForm.ComboBox1.Value
Worksheets("Results").Range("$A2") = UserForm.TextBox1.Value

However, I want it to go to the next cell each time (B3,B4,B5 etc). Now it's
just overwriting the A2 & B2 Valueas.

Thanks!

joel

Save userform values in excel sheet
 
Lastrow = Worksheets("Results").cells(rows.count,"A").end(xl up).Row

Worksheets("Results").Range("$B" & (Lastrow + 1)) = _
UserForm.ComboBox1.Value
Worksheets("Results").Range("$A" & (LastRow + 1)) = _
UserForm.TextBox1.Value


"Hendrik" wrote:

HI,

I'm new to the userforms. I've created on with a combobox and a textbox. In
the same workbook I have a sheet called "Results". When a user clicks "OK" I
want the selected values to populate the results worksheet. It works fine
with the code below:

Worksheets("Results").Range("$B2") = UserForm.ComboBox1.Value
Worksheets("Results").Range("$A2") = UserForm.TextBox1.Value

However, I want it to go to the next cell each time (B3,B4,B5 etc). Now it's
just overwriting the A2 & B2 Valueas.

Thanks!


Hendrik[_2_]

Save userform values in excel sheet
 
Joel, apologies for my late reply. This solves my problem perfectly, thanks!

"Joel" wrote:

Lastrow = Worksheets("Results").cells(rows.count,"A").end(xl up).Row

Worksheets("Results").Range("$B" & (Lastrow + 1)) = _
UserForm.ComboBox1.Value
Worksheets("Results").Range("$A" & (LastRow + 1)) = _
UserForm.TextBox1.Value


"Hendrik" wrote:

HI,

I'm new to the userforms. I've created on with a combobox and a textbox. In
the same workbook I have a sheet called "Results". When a user clicks "OK" I
want the selected values to populate the results worksheet. It works fine
with the code below:

Worksheets("Results").Range("$B2") = UserForm.ComboBox1.Value
Worksheets("Results").Range("$A2") = UserForm.TextBox1.Value

However, I want it to go to the next cell each time (B3,B4,B5 etc). Now it's
just overwriting the A2 & B2 Valueas.

Thanks!



All times are GMT +1. The time now is 03:32 PM.

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