+ Reply to Thread
Results 1 to 23 of 23

How to select and copy desire range

  1. #1
    Registered User
    Join Date
    03-17-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    20

    How to select and copy desire range

    Hi Friends,

    I would like to find a cell having [ specific text(this is fixed) + some numeric value (variable)] till

    [ specific text(this is fixed) + some numeric value (variable)] and then copy past it to column I.

    Book02.xlsx

    eg. I want a RANGE of a cells in column A which has data XYZ 4.65 till ABC 78.65. The words XYZ and ABC will be fixed always however numeric value will be changing "ALONG WITH cell reference number".

    I want this range to be copied in column I.

    Can some one provide me the macro which can perform this operation?

    Regards,

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,052

    Re: How to select and copy desire range

    Try the following macro. Please note that there must be a space between the XYZ and the numeric value and between the ABC and the numeric value.
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    03-17-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: How to select and copy desire range

    Thank you Mumps1 for reply however I dont want input box as i have to run this macro for many different values.

    Also when i tried to run this its showing error.

    .Range(.Cells.Find("XYZ " & firstVal), .Cells.Find("ABC " & secondVal)).Copy .Range("I1")

    Please help.


    Quote Originally Posted by Mumps1 View Post
    Try the following macro. Please note that there must be a space between the XYZ and the numeric value and between the ABC and the numeric value.
    Please Login or Register  to view this content.

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,052

    Re: How to select and copy desire range

    Hi Gauraco. When I tried it on a dummy sheet it worked for me. You have to make sure that there is only one space between the XYZ and the numeric value and between the ABC and the numeric value and you must replace the XYZ and ABC with the actual string you are searching for. How do you determine which numeric value you want to search for?

  5. #5
    Registered User
    Join Date
    03-17-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: How to select and copy desire range

    Ohh I just realized that my data is : Monthly charges $45.76 and next value is Usage charge $33.00 which has spaces.
    This might be creating issue. Can it be possible if it is work for data having spaces?

    Regards.


    Quote Originally Posted by Mumps1 View Post
    Hi Gauraco. When I tried it on a dummy sheet it worked for me. You have to make sure that there is only one space between the XYZ and the numeric value and between the ABC and the numeric value and you must replace the XYZ and ABC with the actual string you are searching for. How do you determine which numeric value you want to search for?

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,052

    Re: How to select and copy desire range

    I am assuming that the first specific text is always going to be "Monthly charges" and the second specific text is always going to be "Usage charges".. Is this correct? Also, if I assume correctly that the dollar amount for each charge will be constantly changing, I need to know how you determine what that charge will be each time you do a search. ?????

  7. #7
    Registered User
    Join Date
    03-17-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: How to select and copy desire range

    Yeah...
    You are absolutely correct. "Monthly charges" and "Usage charges" will always remain only the $ amount will be changing.

    Answer to your 2 question is "Monthly charges" and "Usage charges" are the single entry in column. So I want a data to be copied between this range.

    Thanks.
    Last edited by Gaurao; 01-20-2014 at 03:58 PM.

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,052

    Re: How to select and copy desire range

    Again, I ask: How do you determine which amount you are searching for? Without the answer to this question, it's impossible to go ahead.

  9. #9
    Registered User
    Join Date
    03-17-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: How to select and copy desire range

    Apologize.

    Answer to your 2 question is "Monthly charges" and "Usage charges" are the single entry in column. So I want a data to be copied between this range.

    Thanks.

    Quote Originally Posted by Mumps1 View Post
    Again, I ask: How do you determine which amount you are searching for? Without the answer to this question, it's impossible to go ahead.

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,052

    Re: How to select and copy desire range

    OK, now I understand. Try:
    Please Login or Register  to view this content.

  11. #11
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: How to select and copy desire range

    Hi Gaurao

    If you put a $ in this
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    such as you have in this
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    one of us MAY be able to make this work.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  12. #12
    Registered User
    Join Date
    03-17-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: How to select and copy desire range

    Hi Mumps1,

    I tried this code however there are two issues. your above code is working fine however I want to copy a row which has "Monthly charges (+ numeric value). There are many sentence which are having "Monthly charges" word however I want a cell which has "Monthly charges with any numeric value. This was my original question.

    Secondly its not running or fetching data in sequence. My expectation is it should 1st search "Monthly charges" and then "Usage charges"

    Can it be done?




    Quote Originally Posted by Mumps1 View Post
    OK, now I understand. Try:
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    03-17-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: How to select and copy desire range

    Quote Originally Posted by jaslake View Post
    Hi Gaurao

    If you put a $ in this
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    such as you have in this
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    one of us MAY be able to make this work.
    Hi,

    I cant add $ sign as im fetching data from somewhere else and I have to work on it without manipulating it.

  14. #14
    Registered User
    Join Date
    03-17-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: How to select and copy desire range

    Hi Mumps1,

    I will handle numeric problem. I want your help on this

    Secondly its not running or fetching data in sequence. My expectation is it should 1st search "Monthly charges" and then "Usage charges"

    Can it be done?

    Regards,

  15. #15
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,052

    Re: How to select and copy desire range

    I'm not sure what you mean by "in sequence". You wanted to copy a range between "Monthly charges" and "Usage charges". The code does that. It might be easier to help if you could post a copy of your actual file with a detailed explanation of what you want to do using specific references to cells and/or ranges. If your file contains confidential information, you could replace it with generic data.

  16. #16
    Registered User
    Join Date
    03-17-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: How to select and copy desire range

    Book11.xlsxHi Mumps1,

    Please see attached file. I want to copy highlighted part of excel.

    Quote Originally Posted by Mumps1 View Post
    I'm not sure what you mean by "in sequence". You wanted to copy a range between "Monthly charges" and "Usage charges". The code does that. It might be easier to help if you could post a copy of your actual file with a detailed explanation of what you want to do using specific references to cells and/or ranges. If your file contains confidential information, you could replace it with generic data.

  17. #17
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,052

    Re: How to select and copy desire range

    Hi Gaurao. I had a look at your file but it is still not clear. In the comment you placed on the sheet, you say you want to
    copy a cell having NUMBER, Total amount due, Previous Balance…..and many more things
    Does this mean that you want to copy only row 7, row 14 and row 20? What happened to the range you said you wanted to copy? What are "many more things"? You also say that you want to do the same for all the sheets in the workbook. Do you want to copy to the same sheet each time or copy to a different sheet? I think that the best way to get a clear understanding of what you want is to create a sample file that is as close as possible to your actual file and post it here. Your sample file should include at least two "Before" sheets that show what your data looks like now and two "After" sheets that show what your data will look like after the macro is run. I'm sorry for all these questions, but unless there is a very clear understanding of what you want done, it is very difficult to write a macro that will do what you want.

  18. #18
    Registered User
    Join Date
    03-17-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: How to select and copy desire range

    Hi,

    Thanks for showing interest. I'm OK with your many questions. I'll be glad to answer it.

    I want to copy all the data from row 7 till row 20. I want to copy this data and past it to any of the column of the same sheet. Later I'll run this macro for all the sheets in a workbook.

    I know its bit difficult for you to understand it as my data is confidential so I'm not able to share it.

    I hope this is clear. If not please let me know I'll be happy to answer it.

    Regards.

  19. #19
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,052

    Re: How to select and copy desire range

    Hi Gaurao. Below you will see two macros. The first will work on the active sheet only. The second will work on all the sheets in the workbook since you mentioned that is what you want to do. Both macros assume that you will always be searching in column A for the range between the strings "NUMBER" and "Previous balance". If these search criteria are not always the same, then the code will have to be modified. Please let me know if this works for you.
    Please Login or Register  to view this content.

  20. #20
    Registered User
    Join Date
    03-17-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: How to select and copy desire range

    Hi Mumps1,

    Thank you. Its working fine now. However Can we modify above code when there is no "Previous balance" exist then it should simply exit instead of giving error.

    I ran this macro and got error when my one of the sheet was not having word "Previous balance". Can we eliminate this error?

    Regards,
    Gaurao


    Quote Originally Posted by Mumps1 View Post
    Hi Gaurao. Below you will see two macros. The first will work on the active sheet only. The second will work on all the sheets in the workbook since you mentioned that is what you want to do. Both macros assume that you will always be searching in column A for the range between the strings "NUMBER" and "Previous balance". If these search criteria are not always the same, then the code will have to be modified. Please let me know if this works for you.
    Please Login or Register  to view this content.

  21. #21
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,052

    Re: How to select and copy desire range

    Try:
    Please Login or Register  to view this content.

  22. #22
    Registered User
    Join Date
    03-17-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: How to select and copy desire range

    Hi Mumps1,

    I really THANK YOU VERY MUCH for your help in this. The macro is working nice.

    Have a nice day ahead.

    Regards,
    Gaurao

    Quote Originally Posted by Mumps1 View Post
    Try:
    Please Login or Register  to view this content.

  23. #23
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,052

    Re: How to select and copy desire range

    My pleasure.

+ 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] How to copy data range form one sheet to other sheet with desire Reverse Transpose ?
    By nur2544 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-18-2013, 12:30 PM
  2. select range to copy, find values and copy
    By SarahPintal in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-04-2010, 07:44 PM
  3. select the range and copy
    By ccs_1981 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-17-2009, 04:19 AM
  4. select number range and copy to new tab?
    By papagorgio in forum Excel General
    Replies: 5
    Last Post: 08-26-2009, 11:08 AM
  5. Select range & copy
    By tvac in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-06-2005, 10:13 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