Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have absolutely NO experience in programming Macros (but I can still record Macros, and that is what helps me)

So, I'm asking how to 'slot' this part of a macro, into a whole macro code? Here they are, the whole macro:

    Sub CaseOpen1()
'
' CaseOpen1 Macro
'

'
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
End Sub

And, the part of the macro I want to 'slot in':

    CaseOpen1 Macro
 Dim rng As Range
 Set rng = ActiveSheet.Range("G5")
 '  
 '
 '
 'With rng.Interior
 '

Oh, and if you think there is an error in one of the codes, you can feel free to correct. You're bound to do better than me.

All help appreciated. :)

share|improve this question
    
Just to clarify, the part of the macro I want to slot in was an answer to a question on SuperUser. – Mordecaii Apr 20 '13 at 3:30
    
So you want the second bit of code to be put into the first? Which will make the code only run on cell "G5"? – Amer Apr 20 '13 at 3:38

Like this?

Sub Sample()
    Dim ws As Worksheet
    Dim rng As Range

    '~~> Change this to the relevant worksheet
    Set ws = ThisWorkbook.Sheets("Sheet1")
    Set rng = ws.Range("G5")

    With rng.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
End Sub
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .