#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default VBA Macro

I am trying to get cell (S5) to auto fill when you enter the weight of the
vehicle in cell (W5). If the vehicle weights 50,000 lbs or more it needs to
be classified as a "HEAVY TRUCK". If the weight is less than 50,000 it needs
to be classified as a "LT DUTY TRUCK". If there is no weight filled in I
want to manually enter the classification. My VBA macro I pasted into the
sheet is not working. Can anyone help me fix this? Thanks!

Here is what I have so far

Private Sub Worksheet_Change1(ByVal Target As Range)
If Intersect(Range("W5"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
If Target.Value = 0 Then
Exit Sub
End If
If Target.Value = 50000 Then
Range("S5").Value = "HEAVY TRUCK"
End If
If Target.Value < 50000 Then
Range("S5").Value = "LT DUTY TRUCK"
End If
Application.EnableEvents = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default VBA Macro

Change Cell Ranges to what you want and you should be good to go.

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("A5"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
If Target.Value = 0 Then
Exit Sub
End If
If Target.Value = 50000 Then
Range("C5").Value = "HEAVY TRUCK"
End If
If Target.Value < 50000 Then
Range("C5").Value = "LT DUTY TRUCK"
End If
Application.EnableEvents = True
End Sub


"Thomas Price" wrote:

I am trying to get cell (S5) to auto fill when you enter the weight of the
vehicle in cell (W5). If the vehicle weights 50,000 lbs or more it needs to
be classified as a "HEAVY TRUCK". If the weight is less than 50,000 it needs
to be classified as a "LT DUTY TRUCK". If there is no weight filled in I
want to manually enter the classification. My VBA macro I pasted into the
sheet is not working. Can anyone help me fix this? Thanks!

Here is what I have so far

Private Sub Worksheet_Change1(ByVal Target As Range)
If Intersect(Range("W5"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
If Target.Value = 0 Then
Exit Sub
End If
If Target.Value = 50000 Then
Range("S5").Value = "HEAVY TRUCK"
End If
If Target.Value < 50000 Then
Range("S5").Value = "LT DUTY TRUCK"
End If
Application.EnableEvents = True
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default VBA Macro

Thanks! I am running into one problem. I have a macro before this one and
that is what seems to be the problem. I know that each one works seperatly
but I don't know how to get them both to work. This is what I have.

Private Sub Worksheet_Change1(ByVal Target As Excel.Range)
If Not Application.Intersect(Range("j:k", "y:y"), Target) Is Nothing Then
On Error GoTo ErrHandler
Application.EnableEvents = False
Target.Formula = UCase(Target.Formula)
End If
ErrHandler:
Application.EnableEvents = True
End Sub


Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("W5"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
If Target.Value = 0 Then
Exit Sub
End If
If Target.Value = 50000 Then
Range("S5").Value = "HEAVY TRUCK"
End If
If Target.Value < 50000 Then
Range("S5").Value = "LT DUTY TRUCK"
End If
Application.EnableEvents = True
End Sub


"Office_Novice" wrote:

Change Cell Ranges to what you want and you should be good to go.

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("A5"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
If Target.Value = 0 Then
Exit Sub
End If
If Target.Value = 50000 Then
Range("C5").Value = "HEAVY TRUCK"
End If
If Target.Value < 50000 Then
Range("C5").Value = "LT DUTY TRUCK"
End If
Application.EnableEvents = True
End Sub


"Thomas Price" wrote:

I am trying to get cell (S5) to auto fill when you enter the weight of the
vehicle in cell (W5). If the vehicle weights 50,000 lbs or more it needs to
be classified as a "HEAVY TRUCK". If the weight is less than 50,000 it needs
to be classified as a "LT DUTY TRUCK". If there is no weight filled in I
want to manually enter the classification. My VBA macro I pasted into the
sheet is not working. Can anyone help me fix this? Thanks!

Here is what I have so far

Private Sub Worksheet_Change1(ByVal Target As Range)
If Intersect(Range("W5"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
If Target.Value = 0 Then
Exit Sub
End If
If Target.Value = 50000 Then
Range("S5").Value = "HEAVY TRUCK"
End If
If Target.Value < 50000 Then
Range("S5").Value = "LT DUTY TRUCK"
End If
Application.EnableEvents = True
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
AutoRun Macro with a delay to give user the choice to cancel the macro wanderlust Excel Programming 2 September 28th 07 04:09 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 12:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"