Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.