Consulting

Results 1 to 6 of 6

Thread: Loop Help to find Intersection Cell Address

  1. #1

    Loop Help to find Intersection Cell Address

    I could use some assistance in locating the first column, first row w/ a currency value.
    My current loop is hardcoded w/ the column, 26. I want to run this loop on all sheets in the workbook, and the currency value is in different columns on most of them. So I need to find the first column and the first row w/ a currency value greater than zero.

    [VBA]
    For i = 1 To Cells(Rows.Count, 26).End(xlUp).Row
    If Val(Cells(i, 26)) > 0 Then
    'Cells(i, 26).Copy
    'Wst.Cells(i - 10, 2).PasteSpecial Paste:=xlPasteValues
    'Wst.Cells(i - 10, 2).Value = Wss.Cells(i, 26).Value
    Wst.Cells(i - 10, 2).Value = Cells(i, 26).Value
    If Val(Cells(i, 26)) > 0 Then
    Cells(i, 1).Copy
    Wst.Cells(i - 10, 1).PasteSpecial Paste:=xlPasteValues
    End If
    End If
    Next i
    [/VBA]

    Thanks,
    Doug
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Something like

    [vba]

    For Each cell in Activesheet.UsedRange
    If cell.Value > 0 Then
    cells.Copy
    Wst.Cells(cell.row - 10, 1).PasteSpecial Paste:=xlPasteValues
    End If
    Next cell
    [/vba]

  3. #3
    Hi Bob,
    An issue may exist w/ this I believe is that there are other numerical values on the sheet other than currency values. So I was thinking if we can locate the first row or column w/ a currency value then we can pass this as a variable to my loop to establish the column, replace the hardcoded value of 26, in this case, and perform the copy/paste from here. Does this seem logical/possible?

    thanks,

    Doug
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    How do we differentiate a currency value from any other number?

  5. #5
    I have not dug too deeply, but either w/ a number format using a currency sign, or #.00 is my thought.
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

  6. #6
    Is the correct format to find currency?
    With Application.FindFormat.NumberFormat = "$#,##0.00_);($#,##0.00)"

    If it is, how do I extract the column it finds it in?
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

Posting Permissions

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