I am new to VBA and need assistance badly. I am working a spreadsheet where I need to locate the number '3' in column B and populate the number '2' in the cell above it in column B.
Sub b()
Dim Found As Range
Set Found = Columns("B").Find(what:=3, LookIn:=xlValues, lookat:=xlWhole)
If Not Found Is Nothing Then Found.Offset(-1).Value = 2
End Sub
Sub b()
Dim LR As Long, i As Long
LR = Range("B" & Rows.Count).End(xlUp).Row
For i = 2 To LR
If Range("B" & i).Value = 3 Then Range("B" & i - 1).lvalue = 2
Next i
End Sub
I am getting a run-time error 438...i deleted the first macro and this is the error i am receiving...you are helping me a GREAT deal...thanks for the assistance...looking forward to your reply!
Sub b()
Dim LR As Long, i As Long
LR = Range("B" & Rows.Count).End(xlUp).Row
For i = 2 To LR
If Range("B" & i).Value = 3 Then Range("B" & i - 1).Value = 2
Next i
End Sub
Sub b()
Dim LR As Long, i As Long
LR = Range("B" & Rows.Count).End(xlUp).Row
For i = 2 To LR
If Range("B" & i).Value = 2 Then Range("B" & i - 1).Value = 1
Next i
End Sub
Actually, I have one more thing before I can start filling my template....how can I copy a formula (ie. located in C2) and populate or paste that in column C where the number 2 is present in column B? I hope I explained it right. I will use this for another formula to apply to column B's number 1 entries....thanks!
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.