+ Reply to Thread
Results 1 to 14 of 14

Fill columns botom up fashion (editing current code)

  1. #1
    Registered User
    Join Date
    07-11-2008
    Location
    Toronto
    Posts
    50

    Fill columns botom up fashion (editing current code)

    hey all, I have a piece of code that prompts me to choose which column to be filled bottom up, I would like to modify this and add it in as a macro so that it fills columns H and columns I in a bottom-up fashion

    Please Login or Register  to view this content.

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650
    Hi, This should do the trick:-
    Please Login or Register  to view this content.
    Regards Mick

  3. #3
    Registered User
    Join Date
    07-11-2008
    Location
    Toronto
    Posts
    50
    Thanks alot Mick, that was amazingingly quick, I love you guys.

  4. #4
    Registered User
    Join Date
    07-11-2008
    Location
    Toronto
    Posts
    50

    Need help again

    After must use, the same database is giving me an error when I run the macro,

    Dim Last As Integer, Dn As Integer, oLt As String
    Dim rng As Range, Col As String, Co As Integer


    For Co = 1 To 2
    If Co = 1 Then Col = "H"
    If Co = 2 Then Col = "I"


    Last = Range(Col & Rows.Count).End(xlUp).Row + 1

    For Dn = Last To 1 Step -1
    oLt = Cells(Dn, Col).Value

    Do While oLt = Cells(Dn, Col) Or Cells(Dn, Col) = ""
    Cells(Dn, Col) = oLt
    If Dn = 1 Then Exit For
    Dn = Dn - 1
    Loop
    Dn = Dn + 1
    Next Dn

    Next Co

    End Sub
    The line
    Last = Range(Col & Rows.Count).End(xlUp).Row + 1
    is giving an error, something like run time '6' Overflow

    I tried different techniques and then I tried to run the code dividing my database in two halves and it worked, can it be my database is too big? Im not sure as to why it is doing that when I run my whole database but when I halved it and did it in two parts it worked? any help would be appreciated.
    Last edited by opg; 01-05-2009 at 02:06 PM.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    You're getting an overflow error.

    Variables that refer to row numbers should be Longs, not Integers.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    07-11-2008
    Location
    Toronto
    Posts
    50
    Helllo Shg, happy new year by the way,


    can you please tell me me which one of the variables at the top needs to be declared as Long to fix this problem ?

  7. #7
    Registered User
    Join Date
    07-11-2008
    Location
    Toronto
    Posts
    50
    sorry for the double post
    Last edited by opg; 01-05-2009 at 02:29 PM.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Can you explain what you're trying to do?

    The code you have commits the cardinal sin of changing a loop counter inside a loop.

  9. #9
    Registered User
    Join Date
    07-11-2008
    Location
    Toronto
    Posts
    50
    Hello shg, this code does the following,

    I have parameters that have columns H and I blank lets call those X, and in the same database there are parameters lets call them Y, that have columns H and I filled and they correspond to the empty columns found in H and I of parameter X.

    Now, Parameter Y ALWAYS occurs after parameter X hence, we have a bunch of parameter X in a row with empty columns, H and I, and preceeding them theres parameter Y containing values in column H and column I.

    Objective: I would like to take those columns of H and I of parameter Y and fill the blank columns of parameter X in a bottom up fashion so that everytime it hits that next parameter Y, with it's NEW data columns H and I, the above parameter X will take on those NEW values and continue filling untill it reaches the top.


    Best explained with an example

    and lastly, the original code works like a charm up untill now, the ONLY thing that has changed is that the database has increased,

    this current database that the code is required to work for is 18107 rows of data A-J columns I do not want to limit the code because the database will probably only get bigger/ relatively stay the same.
    Attached Files Attached Files
    Last edited by opg; 01-06-2009 at 04:06 PM.

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Ah.

    Try this:
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    07-11-2008
    Location
    Toronto
    Posts
    50
    SHG, thanks for the quick response, It appears as though the code works fine on a smaller size database but not my current large one, I believe that the code does what its exactly supposed to do,

    I found out my problem and I posted it on forums already, basically my database is so big that if I highlight it right now and hit ctrl+c in an attempt to copy it (applied auto filter on it) and paste it on another worksheet, I get a prompt that says,

    Miscrosoft excel cannot create or use the data range reference because it is too complex

    -use data that can be selected in one contiguous rectangle ( my data is not one contiguous rectangle)


    Now this really has thrown me off but atleast I know that thats where my problem lies, any suggestions are welcomed, I am beat

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    OK, try this:
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    07-11-2008
    Location
    Toronto
    Posts
    50
    Thanks for all your help and most of all your time to help me,SHG I will have to work with it, hopefully I can sort it out.

  14. #14
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    If you wish to continue to receive help then please follow the forum rules below as yout close to a ban

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

+ 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. Columns of data ... need a macro that can find differences of 0.06 & Fill Color them
    By rocket1406 in forum Excel Programming / VBA / Macros
    Replies: 28
    Last Post: 08-27-2007, 03:16 AM
  2. Replies: 0
    Last Post: 06-29-2007, 11:16 AM
  3. Replies: 4
    Last Post: 04-26-2007, 02:13 AM
  4. Replies: 1
    Last Post: 11-12-2006, 06:08 AM
  5. VBA code & Rows or Columns insert
    By smarta in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-28-2006, 10:10 PM

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