VB Script, Change cell values based on column values?

kangi26

New Member
Joined
Apr 28, 2015
Messages
2
Hi all, complete newb to the forum and was wondering if I could get some help with a VB
I have a multiple tabbed spreadsheet (Sunday-Saturday and a few others that I do not need this VB to run on)
On each of Sun-Sat tabs, I have values in A1:A150(actually, it's all formulas pulled from another tab); and the main data is in B4:CS150
What I would like to do is:
When the value in any Cell A1:A150 = "UNFILLED" I need to have all cells in that row that = "1" change to "M"

I've searched like crazy and all I seem to find is conditional formatting, and have about hit my wits end......


Thanks So much for any assistance!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Here's one way which might work. Put this code in the sheet module of the sheet which you call "another tab".
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim wsName As Variant, r As Long, c As Long
    
    If Not Intersect(Range("A1:A150"), Target) Is Nothing Then
        For Each wsName In Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")
            With ThisWorkbook.Worksheets(wsName)
                For r = 1 To 150
                    If .Cells(r, 1).Value = "UNFILLED" Then
                        For c = .Columns("B").Column To .Columns("CS").Column
                            If .Cells(r, c).Value = 1 Then .Cells(r, c).Value = "M"
                        Next
                    End If
                Next
            End With
        Next
    End If
    
End Sub
An alternative approach is similar code in the ThisWorkbook Workbook_SheetCalculate event handler.
 
Upvote 0

Forum statistics

Threads
1,213,487
Messages
6,113,943
Members
448,534
Latest member
benefuexx

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