Reference a cell to copy data + cell shading – is this possible?

Canadian_Newb

New Member
Joined
Jun 30, 2011
Messages
31
This is what I would like to have done:

On Sheet1 I want to reference a cell in Sheet2 (simple =Sheet2!B2 for example). Aside from the data that is in the referenced cell, I would like to copy the cell shading itself. I am not entirely sure if that’s possible and if so, how might this be accomplished? Is there a combination of formulas that can do this or would it be a VBA script?

Any guidance would be much appreciated :)

Thanks!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
This will work if Cell C1 on Sheet 1 is the cell you want to manipulate based on what is in cell B2 on Sheet 2.

Code:
Sub test123()
'
Dim fill_pattern As String
Dim fill_color As String
    'Cell C1 on Sheet1 is the target to be populated with value and fill from cell B2 on Sheet2
    Sheets("Sheet1").Select
    Range("C1").Select
    ActiveCell.FormulaR1C1 = "=Sheet2!R[1]C[-1]"
    Sheets("Sheet2").Select
    Range("B2").Select
    
    With Selection.Interior
    
        fill_pattern = .Pattern
        fill_color = .Color
        
    End With
    
    Sheets("Sheet1").Select
    Range("C1").Select
    
    With Selection.Interior
    
        .Pattern = fill_pattern
        .Color = fill_color
        
    End With
        
End Sub

The pattern (default is usually solid) and color (default is usually yellow) will be transferred to your target of C1 on Sheet 1.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,207,011
Messages
6,076,144
Members
446,187
Latest member
LMill

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