Consulting

Results 1 to 11 of 11

Thread: Need VBA out- put to different location on worksheet.

  1. #1
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location

    Need VBA out- put to different location on worksheet.

    I have data that is placed in columns ABCDE and need this data to be moved into Columns BCDEF which will then will have to move the macro Sub M_snb() which it look at the the data and what ever is uncolored currently result in columns GHIJK row 46. so I need the VBA to results, instead to be placed in columns AL AM AN AO AP ROW 9; this will be its permanent position. I had attached file. Thank you!

    p.s. also the data in the columns ABCDE that will be placed in to Columns BCDEF will change meaning data will be added so the macro has to be able follow where the uncolored values are any where in the columns. the attachment gives a clear picture. please,
    Thank you!
    Attached Files Attached Files
    Last edited by estatefinds; 03-16-2016 at 02:24 PM.

  2. #2
    VBAX Tutor PAB's Avatar
    Joined
    Nov 2011
    Location
    London (UK)
    Posts
    243
    Location
    Hi Dennis,

    Change the Macro to this...

    Sub M_snb()
        sn = Cells(9, 2).CurrentRegion
         
        For j = 1 To UBound(sn)
            For jj = 1 To UBound(sn, 2)
                If InStr(c00, " " & sn(j, jj) & " ") <> 0 Then sn(j, jj) = "~"
                c00 = c00 & " " & sn(j, jj) & " "
            Next
        Next
         
        For j = 1 To UBound(sn)
            sp = Filter(Application.Index(sn, j), "~", 0)
            For jj = 1 To UBound(sn, 2)
                sn(j, jj) = ""
                If jj - 1 <= UBound(sp) Then sn(j, jj) = sp(jj - 1)
            Next
            If UBound(sp) > -1 Then c01 = c01 & " " & j
        Next
        sp = Application.Transpose(Split(Trim(c01)))
         
        Cells(45, 7).Resize(UBound(sp), UBound(sn, 2)) = Application.Index(sn, sp, Array(1, 2, 3, 4, 5))
    End Sub
    I hope this helps!
    -----------------------------------------∏-

    12:45, restate my assumptions.
    Mathematics is the language of nature.
    Everything around us can be represented and understood through numbers.
    If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.

    -----------------------------------------∏-

  3. #3
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    thank you!, ok so I moved the DATA from ABCDE to BCDEF now I need the results of the data instead of placed into GHIJK starting on row 46 instead placed to the Columns AL AM AN AO AP on row 11. also can thus macro be made so where ever the data is in this columns the Macro will still run? I ask cause more data will be added and the unfilled numbers will change. please,
    Thank you

  4. #4
    VBAX Tutor PAB's Avatar
    Joined
    Nov 2011
    Location
    London (UK)
    Posts
    243
    Location
    Hi Dennis,

    Give this a go...

    Sub M_snb()
        sn = Cells(9, 2).CurrentRegion
         
        For j = 1 To UBound(sn)
            For jj = 1 To UBound(sn, 2)
                If InStr(c00, " " & sn(j, jj) & " ") <> 0 Then sn(j, jj) = "~"
                c00 = c00 & " " & sn(j, jj) & " "
            Next
        Next
         
        For j = 1 To UBound(sn)
            sp = Filter(Application.Index(sn, j), "~", 0)
            For jj = 1 To UBound(sn, 2)
                sn(j, jj) = ""
                If jj - 1 <= UBound(sp) Then sn(j, jj) = sp(jj - 1)
            Next
            If UBound(sp) > -1 Then c01 = c01 & " " & j
        Next
        sp = Application.Transpose(Split(Trim(c01)))
         
        Cells(11, 38).Resize(UBound(sp), UBound(sn, 2)) = Application.Index(sn, sp, Array(1, 2, 3, 4, 5))
    End Sub
    I hope this helps!
    -----------------------------------------∏-

    12:45, restate my assumptions.
    Mathematics is the language of nature.
    Everything around us can be represented and understood through numbers.
    If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.

    -----------------------------------------∏-

  5. #5
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    Thank you! it is now where it needs to be Thank you!!!!

  6. #6
    VBAX Tutor PAB's Avatar
    Joined
    Nov 2011
    Location
    London (UK)
    Posts
    243
    Location
    You're welcome, thanks for the feedback.
    -----------------------------------------∏-

    12:45, restate my assumptions.
    Mathematics is the language of nature.
    Everything around us can be represented and understood through numbers.
    If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.

    -----------------------------------------∏-

  7. #7
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    i am having trouble with this it is taking the numbers in column A and placing with data that is only supposed to be data in columns BCDEF can you help me fix this? please?

  8. #8
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    i dont understand what happend?

  9. #9
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    I got it working again Thanks

  10. #10
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    okay i need help this is not working the way its supposed to.

    the only data is supposed to be in columns AL:AP are from BCDEF. the column A gets left alone is that is used for another macro. Please help me Correct this!
    Thank you
    Attached Files Attached Files

  11. #11
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    can this code be re written to avoid the data in column A? reason is that data in column A is what is used for my highlighting if data in BCDEF. but when i run the macro Sub M_snb() sn = Cells(9, 2).CurrentRegion

    For j = 1 To UBound(sn)
    For jj = 1 To UBound(sn, 2)
    If InStr(c00, " " & sn(j, jj) & " ") <> 0 Then sn(j, jj) = "~"
    c00 = c00 & " " & sn(j, jj) & " "
    Next
    Next

    For j = 1 To UBound(sn)
    sp = Filter(Application.Index(sn, j), "~", 0)
    For jj = 1 To UBound(sn, 2)
    sn(j, jj) = ""
    If jj - 1 <= UBound(sp) Then sn(j, jj) = sp(jj - 1)
    Next
    If UBound(sp) > -1 Then c01 = c01 & " " & j
    Next
    sp = Application.Transpose(Split(Trim(c01)))

    Cells(11, 38).Resize(UBound(sp), UBound(sn, 2)) = Application.Index(sn, sp, Array(1, 2, 3, 4, 5))
    End Sub
    it picks up the data in column A which if the code is written in a way to ignore the column A. Please!!!
    Thank you!

Posting Permissions

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