+ Reply to Thread
Results 1 to 2 of 2

Problems with a vba macro

  1. #1
    Registered User
    Join Date
    05-13-2014
    MS-Off Ver
    Excel 2010 & 2019
    Posts
    21

    Problems with a vba macro

    Hey guys,

    I can't seem to get a certain code working...

    It's the if loop where it stops. Do you guys have any ideas on this?
    It should insert rows and add formulas based on some conditions, when there are no more values, the routine needs to stop..


    CODE

    Sub seperatedumpsconvert()

    Dim a As Integer, b As Integer

    Rows(6).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Cells(6, 2).Formula = "=A7"

    Range("A8").Select

    a = ActiveCell.Row
    b = ActiveCell.Column


    Do

    If Cells(a, b).Value = Cells(a - 1, b + 1).Value Then


    ElseIf Cells(a, b).Value > Cells(a - 1, b + 1).Value Then
    Rows(a).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Cells(a, b).Formula = "=B" & a - 1
    Cells(a, b + 1).Formula = "=A" & a + 1


    ElseIf Cells(a, b).Value < Cells(a - 1, b + 1).Value Then
    Rows(a).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Cells(a, b).Formula = "=B" & a - 1


    End If

    a = a + 1

    Loop Until Cells(a + 1, b).Value = ""


    End Sub

  2. #2
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Problems with a vba macro

    what is your code for after first then and before first elseif...?


    regards
    Vikas gautam


    Don't forget to click *

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro Problems
    By mastermind in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-14-2006, 04:40 AM
  2. Macro Problems
    By gillj in forum Excel General
    Replies: 1
    Last Post: 05-06-2006, 06:51 AM
  3. Macro Problems
    By bern in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2005, 07:46 PM
  4. macro problems
    By toolpusher in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-18-2005, 10:06 AM
  5. [SOLVED] macro problems
    By John Garate in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-12-2005, 06:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1