Newbie Question: Need to autofill a range of cells based on values from another worksheet

historygirl28

New Member
Joined
May 5, 2014
Messages
2
I'm trying to autofill a range in Sheet1 with an formula that calls data from Guests (another worksheet in the same workbook). But I need it to end at the last row of data from the Guests worksheet. The macro runs currently, but I don't want to have to change the range every time. And this macro will be used on varying numbers of rows.

Code:
Sub SpsName()
'
' SpsName Macro
'  
    ActiveCell.FormulaR1C1 = _
        "=IF(AND(ISTEXT(Guests!RC[47]),ISNUMBER(SEARCH(""FALSE"",Guests!RC[48]))),Guests!RC[47],"" "")"
    Range("C2").Select
    Selection.AutoFill Destination:=Range("C2:C231"), Type:=xlFillDefault
        Columns("C:C").EntireColumn.AutoFit
   
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Maybe this
Code:
Sub SpsName()
Dim lr As Long
lr = Sheets("Guests").Cells(Rows.Count, "AV").End(xlUp).Row 'Change column reference to suit
Range("C2:C" & lr).Formula = "=IF(AND(ISTEXT(Guests!AU2),ISNUMBER(SEARCH(""FALSE"",Guests!AV2))),Guests!AU2,"" "")"
Columns("C:C").EntireColumn.AutoFit
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,517
Messages
6,125,287
Members
449,218
Latest member
Excel Master

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