Specific value from excel sheet on to the userform.

Windy borough

New Member
Joined
Nov 3, 2018
Messages
35
I need help showing a cell value from excel sheet onto the UserForm1

VBA code below is in my UserForm1


Private Sub UserForm_Initialize()


Dim i As Long
For i = 1 To ThisWorkbook.Sheets.Count
Me.ComboBox1.AddItem ThisWorkbook.Sheets(i).Name
Next

End Sub


Private Sub CommandButton1_Click()


Dim dcc As Long
Dim abc As Worksheet, pfl As Worksheet


Set abc = ThisWorkbook.Worksheets(Me.ComboBox1.Value)
Set pfl = Sheets("ProfitLoss")


With abc


dcc = .Range("A" & Rows.Count).End(xlUp).Row


.Cells(dcc + 1, 1).Value = Date
.Cells(dcc + 1, 2).Value = Me.TextBox1.Value
.Cells(dcc + 1, 3).Value = Me.TextBox2.Value
.Cells(dcc + 1, 4).Value = Me.TextBox3.Value
.Cells(dcc + 1, 5).Value = Me.TextBox4.Value
.Cells(dcc + 1, 6).Value = Me.TextBox5.Value


End With


With pfl
dcc = .Range("A" & Rows.Count).End(xlUp).Row


.Cells(dcc + 1, 1).Value = Date
.Cells(dcc + 1, 2).Value = Me.TextBox1.Value
.Cells(dcc + 1, 3).Value = Me.TextBox2.Value
.Cells(dcc + 1, 4).Value = Me.TextBox3.Value
.Cells(dcc + 1, 5).Value = Me.TextBox4.Value
.Cells(dcc + 1, 6).Value = Me.TextBox5.Value
End With


TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""




End Sub



In workbooks every month have its own sheet so that makes it 12 sheets and one extra in which some data goes automatically when UserForm1 is used. I've made a TextBox6 to display cell value from any of the active sheets in the workbook. On sheet(s) all have same headings and columns so no difference. Columns G's last row should display its value on UserForm1 and auto update itself as user enters data. For me it's difficult since I don't know any VBA. I'd appreciate it very much if somebody can help me achieve this. Your help is much appreciated. Thanks in advance for your help.

Cheers.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Anybody? No?

Hi,
This is a voluntary board so Just need to be a little patient in waiting for a response.

Just to ensure I fully understand your question – do you want content of new TextBox6 to populate Column G in same way other TexBoxes populate Columns B to F ? or something else ?, if so please explain further.

Dave
 
Upvote 0
Hello @Dave. Thanks for the reply. I know a lot of people asking questions and I appreciate every person who tries to help them, I really do and I apologies if I came across as bit rude and such. It wasn't my intention to sound pushy. Anyway you are correct in understanding the question. I do apologies for my explanation, reason being I don't have an excel background and not familiar with it's terms and such so I struggle in explaining the question at times. I got that part of function working now. I do have another question which I will be posting in a few mins and if anybody can help me with that I'd appreciate it very much. Once again many thanks. Cheers.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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