+ Reply to Thread
Results 1 to 23 of 23

Help with range

  1. #1
    Registered User
    Join Date
    06-01-2014
    Posts
    79

    Help with range

    I have a workbook that I want to take all the information in specific cells and put them into a database. I have created a string called myCopy, but when i set it as a range it's giving me an error.
    HTML Code: 

    here is the attached workbook
    Chemical Field Ticket.xlsm

    thank you

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Help with range

    You can't set a range like that... but try this one:

    Please Login or Register  to view this content.
    Changes in red.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    06-01-2014
    Posts
    79

    Re: Help with range

    thank you very much. This fixes the error but I want the total "F35" to be in column C in the database. It won't record the f35 value and is showing up blank. is that because the array needs to be in order from cells left to right?

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Help with range

    ty for the rep jmcconvile
    Does that mean it worked for you? If so, please mark the thread as solved?
    Oh I see you posted...

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Help with range

    I don't follow... specific questions are hard to answer with no context....

    I can tell you what you are trying to do exactly, but I'll try to figure out what the code does

  6. #6
    Registered User
    Join Date
    06-01-2014
    Posts
    79

    Re: Help with range

    no it shouldn't. It's a formula based on the subtotal and sales tax on the excel sheet. I'm just trying to reorder this in the database and have it put F35 into column C

  7. #7
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Help with range

    The range is probably in order, the first cell would be C6, not F35 regardless of how the range is set up (which was F35 first)

  8. #8
    Registered User
    Join Date
    06-01-2014
    Posts
    79

    Re: Help with range

    is there anyway to change that?

  9. #9
    Registered User
    Join Date
    06-01-2014
    Posts
    79

    Re: Help with range

    I can see that it did in fact add the total to the end of the database. so it must just be the order it puts it in

  10. #10
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Help with range

    Bit hard to do this without the data... but I went back to using the array instead of the range for the part that copies values... see if it does what you want?

    Please Login or Register  to view this content.

  11. #11
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Help with range

    You can of course set a range like that but in your case the myCopy string is exceeding the 255 characters limit.
    To handle this situation, you may declare two strings like myCopy1 and myCopy2 and then use Union to set a range.

    Try this.....
    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  12. #12
    Registered User
    Join Date
    06-01-2014
    Posts
    79

    Re: Help with range

    with that last code i get "Invalid next control variable reference". the cell on the input sheet displays $477

    Chemical Field Ticket.xlsm

  13. #13
    Registered User
    Join Date
    06-01-2014
    Posts
    79

    Re: Help with range

    thanks for your help. With this code i have the same problem. It seems to be assigning each cell to the database columns by numeric order. The F35 cell is still being put in the last column of the database even though it's shown 1st on the list

  14. #14
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Help with range

    oops needs fiixng.
    Last edited by Arkadi; 06-19-2015 at 11:41 AM.

  15. #15
    Registered User
    Join Date
    06-01-2014
    Posts
    79

    Re: Help with range

    using your last response I still get an error eluding to Next myCell. it says invalid next control variable reference

  16. #16
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Help with range

    OOOOh... doh thought i'd fixed before pasting... change "next myCell" to "next i"

  17. #17
    Registered User
    Join Date
    06-01-2014
    Posts
    79

    Re: Help with range

    what variable should I define "i" as? I defined it as a long after receiving the "variable not defined" error

  18. #18
    Registered User
    Join Date
    06-01-2014
    Posts
    79

    Re: Help with range

    Here is what I have. The red is where the error comes up saying Variable not defined

    HTML Code: 

  19. #19
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Help with range

    Well that's not with my posted code, but yeah in my version it would need a dim i as long

  20. #20
    Registered User
    Join Date
    06-01-2014
    Posts
    79

    Re: Help with range

    the next error I get, after defining i as long, is "variable not defined" for the myCopy in

    HTML Code: 


    HTML Code: 

  21. #21
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Help with range

    That's because it is a combination of 2 versions... mine being part of it. With this:

    Please Login or Register  to view this content.
    it is probably closer, but I think you said something about $477 ending up somewhere, not sure what that was about, but I had forgotten to change "next myCell" to next i.. which I fixed here.

  22. #22
    Registered User
    Join Date
    06-01-2014
    Posts
    79

    Re: Help with range

    that works! thanks

  23. #23
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Help with range

    finally! Sorry that took so long. Glad we got it sorted out

+ 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. Loop through each folder copy values from range in file1 to named range in file2
    By dafella in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-16-2015, 05:19 PM
  2. Replies: 4
    Last Post: 08-04-2014, 04:48 AM
  3. [SOLVED] Count number of occurances below a range, within a range, and below a range
    By maacmaac in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-15-2013, 11:36 PM
  4. [SOLVED] Copy data from a range of cells into a blank range based on common cell
    By vanmeterkj in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-03-2012, 10:18 AM
  5. send to range, popup box to input what the range should be each time/select range
    By lax2734 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-26-2012, 01:37 AM

Tags for this Thread

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