Simple Macro

Joined
Jul 14, 2015
Messages
1
Reaction score
0
I'm trying to have this Macro run through the entire column. I'm spanking new to macro code and I'm surprised I got this far. See below and let me know what to add so it runs the entire column. I really appreciate everyone's help.

Sub notes()
If Sheet1.Range("g1").Value = "" Then
Sheet1.Range("G1").Value = Sheet1.Range("H1").Value
End If
End Sub
 
Code:
Sub Macro1()
    Dim rng         As Range
    Dim rngG        As Range
    Dim calcMode    As XlCalculation

    With Sheet1
        Set rngG = Intersect(.Columns("G"), .UsedRange)
    End With


    If Not rngG Is Nothing Then
        Debug.Print rngG.Address        '<-for test only

        With Application
            .EnableEvents = False
            calcMode = .Calculation
            .Calculation = xlCalculationManual
            .ScreenUpdating = False
        End With

        For Each rng In rngG
            With rng
                If IsEmpty(.Value) Then
                    .Value = .Offset(, 1).Value
                End If
            End With
        Next rng

        With Application
            .Calculation = calcMode
            .EnableEvents = True
        End With
    End If
End Sub

Artik
 
Back
Top