If statement to change cells

Gummyworms1234

New Member
Joined
Jul 18, 2019
Messages
28
I am trying to use an if statement to change cells to the location number in the corresponding row. I only need to apply the if statement to rows 10 and below. Rows 9 and above are using a different if statement linked to another tab. I want to change an 8 to the corresponding location for each row and if there’s an off in the cell, I want to change the cell to show x. I’ve tried a few variations but I didn’t have any luck with it. The first image shows how it currently looks and the second image is how I want it to be. Thanks for the help!
 

Attachments

  • Excel1.PNG
    Excel1.PNG
    19.7 KB · Views: 10
  • Excel2.PNG
    Excel2.PNG
    20.9 KB · Views: 10

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
This should get the ball rolling. Let us know if you have any problems


Book1
ABCDEFGH
1
2
3
4Locationsunmontuewedthusfrisat
510011001100110011001xxx
61002xx10021002xxx
710031003100310031003xxx
810041004xxxxxx
9100510051005xxxxx
1010068888offoffoff
111007offoff88offoffoff
1210088888offoffoff
1310098888offoffoff
1410108offoffoffoffoffoff
15101188offoffoffoffoff
16
17
18
19
20Locationsunmontuewedthusfrisat
2110011001100110011001xxx
221002xx10021002xxx
2310031003100310031003xxx
2410041004xxxxxx
25100510051005xxxxx
2610061006100610061006xxx
271007xx10071007xxx
2810081008100810081008xxx
2910091009100910091009xxx
3010101010xxxxxx
31101110111011xxxxx
If Statement
Cell Formulas
RangeFormula
B26:H31B26=IF(B10=8,$A26,IF(B10="off","x",""))
 
Upvote 0
The formula isn't doing what I thought it would do. In my head, I didn't think it needed to be applied to B26:H31 because that was how I wanted it to look like. Range B10:H15 is what I wanted to change. Can the formula be adjusted to work with that specific range starting with B10?
 
Upvote 0
Gummyworms1234 To some degree I believe we all look at an Excel problem and think this should do what I am thinking it should do. But then when it doesn't work it's back to the drawing board. Now what you are suggesting would give us a circular error. We just can't put a formula in a cell with a reference to that same cell. Now the thing about excel is if we can't come in thru the front door we will just go around to the back door. Or a side door. There are just so many ways to accomplish what you want to do. Such as a VBA program just to name one. If you still want to keep the discussion going let us know.

VBA Code:
Sub Change1()

Dim Row1 As Long
Dim Col1 As Long

For Row1 = 10 To 15
 For Col1 = 2 To 8
    If Cells(Row1, Col1) = 8 Then
        Cells(Row1, Col1) = Cells(Row1, 1)
    ElseIf Cells(Row1, Col1) = "off" Then
        Cells(Row1, Col1) = "x"
    End If
 Next Col1

Next Row1
End Sub
 
Upvote 0
Gummyworms1234 To some degree I believe we all look at an Excel problem and think this should do what I am thinking it should do. But then when it doesn't work it's back to the drawing board. Now what you are suggesting would give us a circular error. We just can't put a formula in a cell with a reference to that same cell. Now the thing about excel is if we can't come in thru the front door we will just go around to the back door. Or a side door. There are just so many ways to accomplish what you want to do. Such as a VBA program just to name one. If you still want to keep the discussion going let us know.

VBA Code:
Sub Change1()

Dim Row1 As Long
Dim Col1 As Long

For Row1 = 10 To 15
For Col1 = 2 To 8
    If Cells(Row1, Col1) = 8 Then
        Cells(Row1, Col1) = Cells(Row1, 1)
    ElseIf Cells(Row1, Col1) = "off" Then
        Cells(Row1, Col1) = "x"
    End If
Next Col1

Next Row1
End Sub
VBA brings back bad memories of undergrad and I'm trying to avoid it. I actually found an easier way to do what I needed to do after browsing google. Thanks for the help!
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,582
Members
449,039
Latest member
Arbind kumar

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