Consulting

Results 1 to 8 of 8

Thread: Quotes within quotes format problem

  1. #1

    Quotes within quotes format problem

    Hi All,

    I have been trying all day to change the format of an existing (successful) statement so that it uses a variable as part of the range definition, rather than being hard-coded. Can't seem to do it. All rather sad. The statement in question is:

     If Not Intersect(Target, Range("H8:OFFSET(H8,0,0,COUNTA(H:H),1)")) Is Nothing Then
    So instead of having "H8" I would like "H" & FRow, for example. I use this format regularly, but seem unable to manage with the above. Any help would be much appreciated.

    Best regards.

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    hi. try this:

    Range("H8:H" & Cells(Rows.Count, "H").End(xlUp).Row)
    or
    Range("H" & FRow & ":H" & Cells(Rows.Count, "H").End(xlUp).Row)
    Last edited by mancubus; 11-20-2013 at 02:03 PM.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    Thank you, Mancubus. That works perfectly. I would just love to have found the solution using the "OFFSET" format. Now that I have your solution I can spend some free time trying to find the answer.
    My enemy is me. Not brave and strong. Ergo, I feel ashamed. Nothing new there.

    Best regards.

  4. #4
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    You are welcome.

    Range(Range("H8"), Range("H8").End(xlDown))
    Range("H8").Resize(Application.CountA(Columns(8)))
    Range(Range("H8"), Range("H8").Offset(Application.CountA(Columns("H")) - 1))
    Last edited by mancubus; 11-20-2013 at 02:06 PM. Reason: added another method
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  5. #5
    Even more neat solutions. Thank you so much.

  6. #6
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    welcome again.

    yes. there a number of ways to achieve this.

    pls keep in mind that ways in post#4 are for contiguous ranges.

    should there be blank cells in column H, then methods in post#2 will b better to use.

    like:
    Range(Range("H8"), Range("H" & Rows.Count).End(xlUp))
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  7. #7
    Thank you so much, mancubus. I hadn't thought of that. You have been a great help.

    Best regards.

  8. #8
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    I am glad it helped.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

Posting Permissions

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