+ Reply to Thread
Results 1 to 9 of 9

VBA Split Issue

  1. #1
    Registered User
    Join Date
    01-30-2020
    Location
    Planet Earth
    MS-Off Ver
    2016
    Posts
    96

    VBA Split Issue

    Hi,

    I am trying to split a cell and get the lower value of it from one Excel to another

    Please Login or Register  to view this content.
    Any help would be mostly appreciated.

    Thanks!
    Last edited by Gordon85; 03-05-2020 at 10:55 PM.

  2. #2
    Registered User
    Join Date
    01-30-2020
    Location
    Planet Earth
    MS-Off Ver
    2016
    Posts
    96

    VBA Split Issue

    This is the error:

    'Expected array' on vbCr

    Please Login or Register  to view this content.
    Last edited by Gordon85; 03-05-2020 at 10:56 PM.

  3. #3
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,416

    Re: VBA Split Issue

    I believe VBA is complaining about your Cell keyword... it should be Cells (with an "s" at the end).

    You have the (1), which I think should be (0) because the first element of the array produced by the Split function is 0, not 1, in the wrong location. Try it this way...

    wscopy("A" & NR).Value = Split(cell.Offset(0, 1), vbCr)(1)
    Last edited by Rick Rothstein; 03-05-2020 at 10:59 PM.

  4. #4
    Registered User
    Join Date
    01-30-2020
    Location
    Planet Earth
    MS-Off Ver
    2016
    Posts
    96

    Re: VBA Split Issue

    Hi
    Thank you for your fast response, I appreciate it.
    You are right.

    I tried like this:

    Please Login or Register  to view this content.
    Because I want to target the lower part of the cell (as it is literally split into 2 in Excel) but the above code gives the following:

    Runtime error '9' subscript out of range

    If i use (0) after vbCr it gives back the upper part of the cell value..
    Last edited by Gordon85; 03-05-2020 at 11:02 PM.

  5. #5
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,416

    Re: VBA Split Issue

    Reread what I posted in Message #3 as I think I changed it while you were responding to what I wrote initially.

  6. #6
    Registered User
    Join Date
    01-30-2020
    Location
    Planet Earth
    MS-Off Ver
    2016
    Posts
    96

    Re: VBA Split Issue

    Hi,

    My bad, sorry about that.

    I changed it, but it still gives Subscript out of range Runtime error 9 on this line wscopy("A" & NR).Value = Split(cell.Offset(0, 1), vbCr)(1)

    If I change the (1) after vbCr to (0) it will give back the upper part of the cell..while I need the lower part

    Also going offset(0,2) with (0) after vbCr won't help either

  7. #7
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,416

    Re: VBA Split Issue

    I think we might need to see all of the code for the procedure that line of code is in.

    In addition to posting the above requested code, can you show us a few example cell values that you are splitting and show us what you want returned for each of them?

  8. #8
    Registered User
    Join Date
    01-30-2020
    Location
    Planet Earth
    MS-Off Ver
    2016
    Posts
    96

    Re: VBA Split Issue

    Yes, sure, just a moment.

  9. #9
    Registered User
    Join Date
    01-30-2020
    Location
    Planet Earth
    MS-Off Ver
    2016
    Posts
    96

    Re: VBA Split Issue

    Nevermind, solved it, due to syntax.
    Thank you!
    Last edited by Gordon85; 03-06-2020 at 12:19 AM.

+ 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. Offset Alters Entire Range, Need To Offset A Single Cell
    By Genus Max in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-26-2020, 10:47 AM
  2. How to offset previously offset-ed cell ?
    By freshe in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-07-2015, 09:34 AM
  3. Select offset variable offset cells
    By papasmurfuo9 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-02-2014, 06:12 AM
  4. Replies: 3
    Last Post: 06-01-2014, 10:26 AM
  5. function similar to offset to offset the offset
    By Jerseynjphillypa in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-03-2012, 03:07 PM
  6. Reformatting - insert formula with offset, then offset to next cell
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-06-2011, 05:41 AM
  7. Replies: 7
    Last Post: 11-04-2008, 06:41 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