VBA textbox loading value from cell

tfnduarte

New Member
Joined
Sep 14, 2022
Messages
10
Office Version
  1. 2016
Platform
  1. Windows
hi,
i'm starting programming on vba alone.

i'm trying to show on textbox 10 a value from a cell. That should happen when i input a value on textbox 1, but if it's complicate it can be load when the form is open.
The value showed on textbox10 i don't want it to change with keyboard so I locked it in properties.
I've tried many things and happens nothing.
the userform = Preços

VBA Code:
    Private Sub TextBox1_change()
     Folha2.Range("f4").Value = TextBox1
    
    End Sub
    
    Private Sub TextBox10_load_textbox1()
    
       Me.TextBox10.Text = Folha2.Range(g4).Value
    End Sub

VBA Code:
Private Sub Preços_initialize()
    Me.TextBox10.Text = Folha2.Range(g4).Value
End Sub

Anyone can help? thanks.
 

Attachments

  • duvida1.png
    duvida1.png
    14.5 KB · Views: 29

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
it's really need to actualiz the value on textbox10 on change textbox1 because when i input value on textbox 1 it's going to make operations and change the value of the ceel that i want to show on textbox10
 
Upvote 0
If you want to populate textbox10 when textbox1 changes, you need that code in the textbox1_change event (and you need quotes round the range address):

VBA Code:
    Private Sub TextBox1_change()
     Folha2.Range("f4").Value = TextBox1
       Me.TextBox10.Text = Folha2.Range("g4").Value
    End Sub
 
Upvote 0
Solution
If you want to populate textbox10 when textbox1 changes, you need that code in the textbox1_change event (and you need quotes round the range address):

VBA Code:
    Private Sub TextBox1_change()
     Folha2.Range("f4").Value = TextBox1
       Me.TextBox10.Text = Folha2.Range("g4").Value
    End Sub
Thank you.
It worked
newbie errors... :)
 
Upvote 0
If you want to populate textbox10 when textbox1 changes, you need that code in the textbox1_change event (and you need quotes round the range address):

VBA Code:
    Private Sub TextBox1_change()
     Folha2.Range("f4").Value = TextBox1
       Me.TextBox10.Text = Folha2.Range("g4").Value
    End Sub
another question, how to format textbox 10 as currency
 
Upvote 0
If the cell is formatted the way you want, use Folha2.Range("g4").Text rather than Folha2.Range("g4").Value.
 
Upvote 0
VBA Code:
 Private Sub TextBox1_change()
     Folha2.Range("f4").Value = TextBox1
       Me.TextBox10.Text = Folha2.Range("g4").Text
       Me.TextBox35.Text = Folha2.Range("h4").Text
       Me.TextBox51.Text = Folha2.Range("i4").Text
End Sub

When i change .value to .text the values just appear when i click on the textbox why?
 
Upvote 0
I don't know what you mean?
 
Upvote 0
Video userform working

VBA Code:
 Private Sub TextBox1_change()
     Folha2.Range("f4").Value = TextBox1
       Me.TextBox10.Text = Folha2.Range("g4").Text
       Me.TextBox35.Text = Folha2.Range("h4").Text
       Me.TextBox51.Text = Folha2.Range("i4").Text
End Sub

Private Sub TextBox17_Change()
Folha2.Range("f13").Value = TextBox17
  Me.TextBox26.Text = Folha2.Range("g13").Value
    Me.TextBox42.Text = Folha2.Range("h13").Value
    Me.TextBox58.Text = Folha2.Range("i13").Value

So I uploaded a video to see working...
When the
VBA Code:
       Me.TextBox10.Text = Folha2.Range("g4").Text
have to click to appear the values
When the
VBA Code:
       Me.TextBox26.Text = Folha2.Range("g4").Value
the values appear alone
 
Upvote 0

Forum statistics

Threads
1,223,937
Messages
6,175,525
Members
452,651
Latest member
wordsearch

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