+ Reply to Thread
Results 1 to 2 of 2

Looping, which one to use

  1. #1
    Forum Contributor
    Join Date
    01-18-2005
    Posts
    238

    Looping, which one to use

    I have data in column D thru G that needs to be calculated based on column A. However, column A contains both text and a number ex..(Fiesta 2 oz). How can I get a code to loop through all the rows that contain the word Fiesta in column A. Right now I am currently using the For next loop. Where x = 8 to 18 and next x. However this is very inconvenient when I have to insert or delete a row causing me to go back and change everything. Could someone please shed some light. Thanks greatly

    Josh

  2. #2
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    Try this macro

    Sub Macro1()

    Dim k As Integer
    k = 1

    k = 1
    ' K1 = 1
    ini = ""
    Columns("A:A").Select
    While ActiveCell.Address <> ini Or k = 2
    On Error Resume Next

    Selection.Find(What:="anil", After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False).Activate


    If Err.Description <> "" Then

    Err.Clear
    GoTo a:
    Else
    If ini <> ActiveCell.Address Then
    ' your code to calculate value from d through G
    Range(ActiveCell.Offset(0, 6).Address).Value = "testing"
    End If
    If k = 1 Then
    ini = ActiveCell.Address
    End If
    k = k + 1
    K1 = K1 + 1
    'MsgBox K1
    End If
    Wend
    a:

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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