Add text to Range of cells

J

jlclyde

I have a range that I need to add the same text to if the cell is
visible. Is there a way to do this without putting in a loop? Here
is my code.

Thanks,
Jay
Set Rng = .AutoFilter.Range.Offset(1,
0).Resize(.AutoFilter.Range.Rows.Count - 1) _
.SpecialCells(xlCellTypeVisible)

If .Rows(.Rows.Count).Row <> 4 Then
Set Rng = .Range("A5:A" & Lstrow)
Set Rng = Rng.SpecialCells(xlCellTypeVisible)
Rng.Value = Rng.Value & "N"
End If
 
D

Don Guillett Excel MVP

I have a range that I need to add the same text to if the cell is
visible.  Is there a way to do this without putting in a loop?  Here
is my code.

Thanks,
Jay
        Set Rng = .AutoFilter.Range.Offset(1,
0).Resize(.AutoFilter.Range.Rows.Count - 1) _
            .SpecialCells(xlCellTypeVisible)

            If .Rows(.Rows.Count).Row <> 4 Then
                Set Rng = .Range("A5:A" & Lstrow)
                Set Rng = Rng.SpecialCells(xlCellTypeVisible)
                Rng.Value = Rng.Value & "N"
            End If

If ?? every cell in the range ends with the same thing such as M then
columns(1).replace "M", "MN"
else loops shouldn't be too slow these days.
 
J

jlclyde

If ?? every cell in the range ends with the same thing such as M then
columns(1).replace "M", "MN"
else loops shouldn't be too slow these days.

All of the cells do not end with a specific value. Good thinking
though. I know the loop runs fast; I am just wonderign if there is a
way to avoid the loop. I already have several loops in this
subroutine and thought I woudl try to avoid another oner.

Thanks,
Jay
 
D

Don Guillett Excel MVP

All of the cells do not end with a specific value.  Good thinking
though.  I know the loop runs fast; I am just wonderign if there is a
way to avoid the loop.  I already have several loops in this
subroutine and thought I woudl try to avoid another oner.

Thanks,
Jay
"If desired, send your file to dguillett @gmail.com I will only look
if:
1. You send a copy of this message on an inserted sheet
2. You give me the newsgroup and the subject line
3. You send a clear explanation of what you want
4. You send before/after examples and expected results."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Match style 0
Range headings 0
Count After Filter in macro 2
Highlight Text 1
#REF! help please 3
Copy filtered data to sheet 2 1
VBA calculate avg dates 1
add additional code to code 4

Top