Results 1 to 4 of 4

Thread: vba loop in excel

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    could someone help me out with the syntax on a loop that would change this
    0
    0
    0
    0

    into "a" as many times as it might appear it has no set row count each time?????

  2. #2
    Lively Member
    Join Date
    May 2000
    Location
    Norway
    Posts
    112
    Wow. That was hard to understand. Start using punctuations and commas to make yourself better understood.

    I understand this as a search and replace routine for all cells containing "0". You want to replace the "0"s with "a"s, right?

    Do something like this
    Code:
    For y = 1 To NoOfRows
      For x = 1 To NoOfColumns
        If ActiveSheet.Cells(x,y)=0 Then ActiveSheet.Cells(x,y)="a"
      Next x
    Next y

  3. #3
    Fanatic Member coox's Avatar
    Join Date
    Oct 1999
    Posts
    550
    Or you could just cheat and use:
    Code:
        Cells.Replace What:="0", Replacement:="a", LookAt:=xlPart, SearchOrder _
            :=xlByRows, MatchCase:=False
    Which would be cheating, but would work very quickly...

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    i can't get the first example to work -- are x and y variables that i need to give a value to???? help

Posting Permissions

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



Click Here to Expand Forum to Full Width