FillRight method of Range class failed

justinojanson

New Member
Joined
Dec 22, 2015
Messages
3
Hi there..

This is my first post here... I have been using this forum a lot and find it extremely useful, hence I decided to register... :)

Anyways, down to business... I am creating a macro for a project and have got to the point where I have been able to sort data in column "A" according to my criteria, but have run into difficulties with below code:

Code:
Sheets(1).Range("A2:A" & Sheets(1).Range("A" & Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeVisible).Select


Selection.FillRight

Basically, it does select all cells with data in the filtered column, but for whatever reason "FillRight" does not work... :(

Any advice?

Thanks in advance,

Justin
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
PS. I tried using:

Code:
Sheets(1).Range("A2:A" & Sheets(1).Range("A" & Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeVisible).Activate


Selection.FillRight
But that fills the selection into every column of my table
 
Upvote 0
Aaaaand I managed to find a workaround by replacing my previous code with:

Code:
For Each cell In Sheets(1).Range("A2:A" & Sheets(1).Range("A" & Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeVisible)
If cell.Value <> "" Then
            cell.Offset(0, 1).Value = cell.Value
        End If
    Next cell
and getting rid of
Code:
Selection.FillRight
alltogether...

So now my code works...

Thanks anyways to all those, that did look into this...
 
Upvote 0
To fill one column to the right, try:
Code:
    With Sheets(1)
        .Range("A2:B" & .Range("A" & Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeVisible).FillRight
    End With
Basically, you have to tell it the column you want to fill to.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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