+ Reply to Thread
Results 1 to 6 of 6

Copy and paste values for all cells that begin with a certain string

  1. #1
    Forum Contributor
    Join Date
    08-25-2014
    Location
    Pennsylvania, US
    MS-Off Ver
    Windows '16
    Posts
    165

    Copy and paste values for all cells that begin with a certain string

    Hey guys, hope you can help me again. I have some add-ins in Excel that use custom functions to pull data for a larger document. The add-in is not available on all computers that will be using this spreadsheet, so I would like to find all the cells that are dependent on these custom functions (through a COM Add In) and copy and paste values.

    So the cells that need copied and pasted begin with (for example) "=+XYZ(" and "=+XYZTWO(" and they are found in numerous cells across many worksheets (i.e. they're not neatly co-located on one sheet).

    I'm thinking some VBA will solve this. I appreciate any help you can give. Thanks.

  2. #2
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Copy and paste values for all cells that begin with a certain string

    What type of values do you wish to paste into the cells? What datatype?

    Are all workbooks that you want to search open when you run the search?

    If not, are they in the same directory as the workbook that runs the code?

    If not, are they all in the same directory, different than the workbook that runs the code?

  3. #3
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Copy and paste values for all cells that begin with a certain string

    I would try this:

    Please Login or Register  to view this content.
    ...please let me know how that worked.

  4. #4
    Forum Contributor
    Join Date
    08-25-2014
    Location
    Pennsylvania, US
    MS-Off Ver
    Windows '16
    Posts
    165

    Re: Copy and paste values for all cells that begin with a certain string

    Hi joe, thanks for the reply. All the data returned are numbers, and I would like to paste everything as a number. Formatting (some are percents, some are dollar values) is not important as long as the number value remains intact.

    Also, there is only one workbook. One file. There are multiple worksheets. I didn't get a chance to try your code - thanks for posting it. Will it still be appropriate for one workbook across multiple sheets? Thanks a ton!

  5. #5
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Copy and paste values for all cells that begin with a certain string

    It will work because Workbooks is a collection of open workbooks, so it should just loop through one workbook if it's the only one open.

    Please Login or Register  to view this content.
    I changed the code above to reference the workbook the code is written in. That way, if you have other workbooks open, the code will work if the code is stored in the workbook you want to search. I also changed the datatype of "Variant1" and "Variant2" to a Double, which allows you to use just about any number you want. I would change the Variant1 & Variant2 names throughout the code to something more meaningful to you.

  6. #6
    Forum Contributor
    Join Date
    08-25-2014
    Location
    Pennsylvania, US
    MS-Off Ver
    Windows '16
    Posts
    165

    Re: Copy and paste values for all cells that begin with a certain string

    Got it, thank you very much. I am not able to test it now but will tomorrow and I'll let you know how it goes. Thanks!

+ 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 compare two string in two different workbooks and Copy the relevant values & Paste?
    By somani123 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-13-2014, 06:47 AM
  2. [SOLVED] Splitting a string of numbers into separate cells: where to even begin?
    By confused_teacher in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 06-03-2013, 02:33 PM
  3. Replies: 3
    Last Post: 05-11-2013, 01:06 PM
  4. Selecting only cells that begin with certain values.
    By garner.ms in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-29-2012, 10:06 AM
  5. Copy and paste a string of cells into 41 calculated rows and columns
    By rclark430 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2011, 08:15 PM
  6. [SOLVED] Copy/Paste how to avoid the copy of formula cells w/o calc values
    By Dennis in forum Excel General
    Replies: 10
    Last Post: 03-02-2006, 06:50 PM
  7. [SOLVED] VBA to copy sheets (as values) that begin with the same sheet name
    By Brent Walker in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-28-2005, 01:06 PM

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