VBA help please

A1058

New Member
Joined
Sep 13, 2006
Messages
46
hello hoping some nice person here can help me out.
i am trying to make VBA recognize that IF cell A1>0 then grab data from cell B1 and put it into C1. i am dealing with times and dates start and stop times for processing items. currently i have the stop times tied to another cell and they are accurately entered with....
-----------------------------------------
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(Range("H11"), .Cells) Is Nothing Then
Application.EnableEvents = False
With .Offset(-3, 51)
.NumberFormat = "hh:mm:ss"
.Value = Time
End With
Application.EnableEvents = True
End If
End With
------------------------------------------
i have all the stop times being fed into individual cells and a final cell BM46 that =max(BM1:BM45)

you might say why not make each start time = the previous stop time, well in a perfect world that work simply enough. but sometimes in my case certain items end up being skipped or processed out of order thus the 45 cells in column BM...

i need code in vba that will recognize that IF L16 >0 then grab BM46 value and put it into BJ16

... hoping for a helpful answer, i am very new to VBA and cannot find a nice example of how to do this.

thank you much :)
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
See if this is going to work for you.

Assume that Columns L, BM, and BJ are all formatted using the Cell Format of HH:MM:SS

Sub time()

Dim MyRange As Range
Dim MaxTime As Variant

Set MaxTime = Range("BM46")
Set MyRange = Range("L1:L" & Range("L65536").End(xlUp).Row)

For i = 1 To MyRange.Rows.Count Step 1
If Range("L" & i) > 0 Then
Range("BJ" & i).Value = MaxTime
End If
Next i

End Sub
 
Upvote 0
reply

thank you Dan for you quick response. although the L column isnt formatted as you suggested and i cant quite figure how to implement this code or that its even 100% correct. wondering if i might can email you a copy to look over see what you think????
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,003
Members
448,935
Latest member
ijat

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