+ Reply to Thread
Results 1 to 8 of 8

VBA Excel Macro find column name and next need to copy range

  1. #1
    Registered User
    Join Date
    09-17-2021
    Location
    Gdynia
    MS-Off Ver
    2016
    Posts
    66

    VBA Excel Macro find column name and next need to copy range

    I have a part of macro which, after typing in the inputbox, finds the name of the column (date), after finding it, it needs to copy a given fragment of rows from this column, always after finding a given cell, it will be the same range. But i dont knot excatly how please take a look as below code . Here im getting error : Loc.Range("109:123").Copy

    Please Login or Register  to view this content.
    Last edited by Palucci; 09-24-2021 at 06:24 AM.

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,526

    Re: VBA Excel Macro find column name and next need to copy range

    Loc returns a Range object. You would need to use Offset and Resize to copy the proper Range.

    Try something like below to select a range of 15 cells below the found range.

    Please Login or Register  to view this content.
    Last edited by bakerman2; 09-24-2021 at 06:34 AM.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Registered User
    Join Date
    09-17-2021
    Location
    Gdynia
    MS-Off Ver
    2016
    Posts
    66

    Re: VBA Excel Macro find column name and next need to copy range

    Ok thanks, one more question. How to change to select from 109 all rows to right like a below screen Attachment 749080

    With data_wb.Sheets("Final")
    Set loc = .Cells.Find(what:="2021-01-01")
    If Not loc Is Nothing Then
    .Cells(109, loc.Column).Resize(15).Copy
    End If
    End With
    Last edited by Palucci; 09-24-2021 at 10:43 AM.

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,526

    Re: VBA Excel Macro find column name and next need to copy range

    Your attachment is invalid.

  5. #5
    Registered User
    Join Date
    09-17-2021
    Location
    Gdynia
    MS-Off Ver
    2016
    Posts
    66

    Re: VBA Excel Macro find column name and next need to copy range


  6. #6
    Registered User
    Join Date
    09-17-2021
    Location
    Gdynia
    MS-Off Ver
    2016
    Posts
    66

    Re: VBA Excel Macro find column name and next need to copy range

    How to should you whay excalty i want ?

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,526

    Re: VBA Excel Macro find column name and next need to copy range

    Please Login or Register  to view this content.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,861

    Re: VBA Excel Macro find column name and next need to copy range

    Administrative Note:

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

+ 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. [SOLVED] Find Non Blanks in column, copy range to new sheet.
    By marcosis in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-17-2019, 07:43 AM
  2. [SOLVED] Excel VBA Macro - Find Word and Select that Column to Column D and copy
    By MsBBStacker in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-02-2015, 12:04 AM
  3. Find column name and copy used range under header
    By Pierce Quality in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-06-2015, 04:19 PM
  4. [SOLVED] Macro to find the empty cell in a column and copy a adjacent row to another column.
    By naga in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-18-2013, 07:44 AM
  5. [SOLVED] Excel VBA macro to select range separated by blank row and copy to next empty column
    By hackini in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-29-2013, 02:13 AM
  6. [SOLVED] find bold number in Column A and copy range to column C
    By joek13 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-24-2012, 10:32 AM
  7. Replies: 1
    Last Post: 05-06-2011, 03:08 AM

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