Finding a value, offsetting, changing value

saiko

New Member
Joined
Sep 8, 2002
Messages
15
I need to search a spreadsheet for the value "n", then move one row up, and insert the value "0.00".

My code below fails, as excel expects something like
If .Value = "n" Then .Value = 0

Please advise how I get it to move up one cell first, before replacing the value.


For rwIndex = 1 To 300
For colIndex = 1 To 300
With Worksheets("WHA").Cells(rwIndex, colIndex)
If .Value = "n" Then .Offset(-1, 0).Select .Value = 0
End With
Next colIndex
Next rwIndex

Thanks in advance.
David
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I have tried this:
If Selection.Value = "n" Then Selection.Offset(-1, 0) = 0

but get a type mismatch error.
Please help.
 
Upvote 0
Alright mate. Try doing it this way:

Dim rwindex, colindex As Integer
For rwindex = 1 To 9
For colindex = 1 To 9
With Worksheets("Sheet1").Cells(rwindex, colindex)
If .Value = "n" Then
.Select
Selection.Offset(-1, 0).Value = 0
End If
End With
Next colindex
Next rwindex

Hope this works.
 
Upvote 0

Forum statistics

Threads
1,215,651
Messages
6,126,023
Members
449,281
Latest member
redwine77

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