We help IT Professionals succeed at work.
Get Started

How can I modify this macro in Excel?

E=mc2 asked
Last Modified: 2015-02-26
I would like to modify the following macro.

Sub Step3()
    Dim i As Long
    With Application
        .Calculation = xlCalculationManual
        .ScreenUpdating = False
        For i = Selection.Rows.Count To 1 Step -1
            If Selection.Cells(i, 1) = "" And (Selection.Cells(i, 2) = 0 Or _   Selection.Cells(i, 2) = "0.00") Then
            End If
        Next i
        .Calculation = xlCalculationAutomatic
        .ScreenUpdating = True
    End With
End Sub

Open in new window

I have a spreadsheet with 2 columns, Column A and Column B.
Column A usually has numbers such as 12345.  Column B at times is blank or has numbers.

In the following scenario, if it finds a number, in the spreadsheet, say 99999:

99999	    0.00

Open in new window

In the scenario above, when it finds a number which has some 'corresponding' blank fields underneath it, yet has some
numbers in Field B.  It will assume that the last blank row, before another number begins, is the Total.  The script should then move the last number it finds in the first row and insert a 0 in the other rows.

In other words it should end up looking like this.
99999  2000.00

Open in new window

Watch Question
Director, Practice Manager and Computing Consultant
Awarded 2014
Top Expert 2014
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE