Range select in activecell row

DeepBlu24

New Member
Joined
Dec 18, 2017
Messages
9
Hi.

This is such a simple question that I just can't find an answer for that works. Very simply, when a certain cell is the row is filled in, the next cell populated with the Now() function. What I'm trying to do is just then select the active row from the cell that's been filled in with the time & date to the first cell in the row and change the colour of the row. I can get it to work with the Entire row function, but I don't want the entire row coloured, just the range I'm using.
I know there's a simple answer, I just can't get it to work.

this is what I've done:

Public Sub SkillReset() 'adds date & time when a row is reset
Dim reset As Range

Set reset = Range("I3:I10")
For Each cell In reset
If cell.Value <> "" Then
cell.Offset(0, 1).Value = Now()
Range(ActiveCell, ActiveCell.End(xlLeft)).Select 'this is the code that bugs out when I try to add the colour change
ElseIf cell.Value = "" Then
cell.Offset(0, 1).Value = ""
End If
Next
End Sub
 
Last edited:

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
It is not the active cell, and you do not need to select anything

to colour the first 10 columns in the row a nasty green, replace your line with
Code:
ActiveSheet.Cells(cell.Row, "A").Resize(, 10).Interior.Color = 123456

amend to suit your needs eg - this does C:F
Code:
    ActiveSheet.Cells(cell.Row, "C").Resize(, 4).Interior.Color = 123456
 
Last edited:
Upvote 0
Maybe, depending on your data....

Code:
Public Sub SkillReset()    'adds date & time when a row is reset
    Dim reset As Range, cell As Range

    Set reset = Range("I3:I10")
    For Each cell In reset
        If cell.Value <> "" Then
            cell.Offset(0, 1).Value = Now()
            Range(cell.Offset(, -(cell.Column - 1)), cell.Offset(0, 1)).Interior.ColorIndex = 6 'this is the code that bugs out when I try to add the colour change
        ElseIf cell.Value = "" Then
            cell.Offset(0, 1).Value = ""
        End If
    Next
End Sub

or

Code:
Public Sub SkillReset2()    'adds date & time when a row is reset
    Dim reset As Range, cell As Range

    Set reset = Range("I3:I10")
    For Each cell In reset
        If cell.Value <> "" Then
            cell.Offset(0, 1).Value = Now()
            Range(cell.End(xl[COLOR="#FF0000"]To[/COLOR]Left), cell.Offset(0, 1)).Interior.ColorIndex = 6    'this is the code that bugs out when I try to add the colour change
        ElseIf cell.Value = "" Then
            cell.Offset(0, 1).Value = ""
        End If
    Next
End Sub

or

Code:
Public Sub SkillReset3()    'adds date & time when a row is reset
    Dim reset As Range, cell As Range

    Set reset = Range("I3:I10")
    For Each cell In reset
        If cell.Value <> "" Then
            cell.Offset(0, 1).Value = Now()
            Cells(cell.Row, "A").Resize(, cell.Column + 1).Interior.ColorIndex = 6 'this is the code that bugs out when I try to add the colour change
        ElseIf cell.Value = "" Then
            cell.Offset(0, 1).Value = ""
        End If
    Next
End Sub

or even

Code:
Public Sub SkillReset4()    'adds date & time when a row is reset
    Dim reset As Range, cell As Range

    Set reset = Range("I3:I10")
    For Each cell In reset
        If cell.Value <> "" Then
            cell.Offset(0, 1).Value = Now()
            cell.Offset(, -(cell.Column - 1)).Resize(, cell.Column + 1).Interior.ColorIndex = 6 'this is the code that bugs out when I try to add the colour change
        ElseIf cell.Value = "" Then
            cell.Offset(0, 1).Value = ""
        End If
    Next
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,710
Messages
6,174,017
Members
452,542
Latest member
Bricklin

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