macro help

project manager15

New Member
Joined
Mar 11, 2009
Messages
21
Hi,

I have writen a macro and it does what i want it to do but only for row '5' and i need it to go down to row 27.

It means that you can only edit e5 to k5 once O/C/A is pick from the drop down. ie i want people to fill in B5.

There are other cells inbetween but they cant be changed and are not relevent.

any help would be awesome.

can i attach?

mark


Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("e5:k27")) Is Nothing And Target.Count = 1 Then

Select Case Range("b5").Value
Case "O"
Range("E5:K5").Font.ColorIndex = 1

Case "C"
Range("E5:K5").Font.ColorIndex = 1

Case "A"
Range("E5:K5").Font.ColorIndex = 1

Case Else
Range("E5:K5") = 0
Range("E5:K5").Font.ColorIndex = 2
Value = 0
MsgBox "PLEASE COMPLETE O/C/A"

End Select
End If


End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hello and welcome to MrExcel.

Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("E5:K27")) Is Nothing And Target.Count = 1 Then
    Select Case Range("B5").Value
        Case "O"
            Range("E5:K27").Font.ColorIndex = 1
        Case "C"
            Range("E5:K27").Font.ColorIndex = 1
        Case "A"
            Range("E5:K27").Font.ColorIndex = 1
        Case Else
            Application.EnableEvents = False
            Range("E5:K27").Value = 0
            Range("E5:K27").Font.ColorIndex = 2
            MsgBox "PLEASE COMPLETE O/C/A"
            Application.EnableEvents = True
    End Select
End If
End Sub
 
Last edited:
Upvote 0
cheers for the quick reply, but it wont let me enter data in, it just say please enter o/c/a... i need each row (columnB) to be the control of whether data can be entered in each row ie b7 for e7:k7.
 
Upvote 0
Perhaps you meant

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long
If Not Intersect(Target, Range("E5:K27")) Is Nothing And Target.Count = 1 Then
    i = Target.Row
    Select Case Range("B5").Value
        Case "O"
            Range("E" & i & ":K" & i).Font.ColorIndex = 1
        Case "C"
            Range("E" & i & ":K" & i).Font.ColorIndex = 1
        Case "A"
            Range("E" & i & ":K" & i).Font.ColorIndex = 1
        Case Else
            Application.EnableEvents = False
            RRange("E" & i & ":K" & i).Value = 0
            Range("E" & i & ":K" & i).Font.ColorIndex = 2
            MsgBox "PLEASE COMPLETE O/C/A"
            Application.EnableEvents = True
    End Select
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,096
Messages
6,053,516
Members
444,669
Latest member
Renarian

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