extending the (VBA code) functionality to a data-form

buffalo

Board Regular
Joined
Jun 19, 2003
Messages
183
Hi,

So far I have been entering data manually in the excel worksheet. Now this data is "user-friendly"

So for instance, in Column 5: I enter b or buy or Buy..the VBA code reads
that and replaces the cell's value to Buy.

THis, I do for quite a few columns ...with different "final values" in the cells based on the VBA code.

for instance the code looks like

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False

    
    If Target.Row = 1 Then Exit Sub
    
    If Target.Column = 2 Then
   ' anything starting with H or h goes to Hamer, etc...
      
        If Left(UCase(Target.Value), 1) = "H" Then
            Target.Value = "Hamer"
        End If
        
        If Left(UCase(Target.Value), 1) = "M" Then
            Target.Value = "M"
        End If
    End If
    
    If Target.Column = 5 Then 
    ' For anything with B,b, S,s
    
       If Left(UCase(Target.Value), 1) = "B" Then
            Target.Value = "Buy"
        End If
        
        If Left(UCase(Target.Value), 1) = "S" Then
            Target.Value = "Sell"
        End If
    End If
    
    If Target.Column = 6 Then ' For vehicles
    ' another type of user-friendly thing

       Target.Value = UCase(Target.Value)
    End If

Application.EnableEvents = True
End Sub

Now how do I extend this stuff in Data-forms?
When I enter the values, the data is not modified by the VBA code anymore

..any suggestions?

Would using user-forms solve this problem in a better way?

thanks in advance
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
for first time why you need that:

have you unchecked:

tools -> options -> edit -> enabled autocomplete for cell values. ?

and yes useform will be do a better jobs atleast for intermediate users like us..or else see some guru can suggest you to work on data forms of excel.
 
Upvote 0

Forum statistics

Threads
1,214,621
Messages
6,120,563
Members
448,972
Latest member
Shantanu2024

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