Please Help Fixing VBA Code

pure vito

Board Regular
Joined
Oct 7, 2021
Messages
183
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I am using this code to bring up my userform and it populates textboxes within the userform every time I click a value in column "A" and this seems to work fine,

But everything below "TextBox1" seems to come through slower, making the data inaccurate,

It could be the way I have set this up because the values from "Data 3" are taken from a Vlookup,

I will attach images hopefully showing what I'm trying to achieve,

Any help is appreciated,

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("A2:A3000")) Is Nothing Then

    userform1.Show         
            
    userform1.TextBox1.Value = Range(Target.Address).Value
    userform1.Loosefig.Value = Sheets("Data 3").Range("C5").Value
    userform1.Loosedays.Value = Sheets("Data 3").Range("D5").Value
    userform1.Willmake.Value = Sheets("Data 3").Range("E5").Value
    Worksheets("Data 3").Range("B5") = Range(Target.Address).Value
    Worksheets("Data 3").Range("B6") = Range(Target.Address).Value
    
End If

End Sub

1699525272617.png


1699525318457.png
 

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.
This was the fix it was simply the order allowing the vlookup to run first #Learningonthejob 😬

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("A2:A3000")) Is Nothing Then
Application.ScreenUpdating = False
    
    Worksheets("Data 3").Range("B5") = Range(Target.Address).Value
    Worksheets("Data 3").Range("B6") = Range(Target.Address).Value
    userform1.Show         
    userform1.TextBox1.Value = Range(Target.Address).Value
    userform1.Loosefig.Value = Sheets("Data 3").Range("C5").Value
    userform1.Loosedays.Value = Sheets("Data 3").Range("D5").Value
    userform1.Willmake.Value = Sheets("Data 3").Range("E5").Value

 Application.ScreenUpdating = True
End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,184
Members
452,615
Latest member
bogeys2birdies

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