+ Reply to Thread
Results 1 to 10 of 10

paste const value

  1. #1
    Registered User
    Join Date
    08-01-2014
    Location
    Poland
    MS-Off Ver
    14.0.7015.1000
    Posts
    14

    paste const value

    Hi,

    I have a problem with VBA code for pasting const value. Please see attchaed file. In sheet1 I have values in column A. I need to copy them to sheet2 and there in column B be there should be always value a, in column b value c etc for each value from sheet1. Could you please help with this issue?

    Thanks in advance.

    Best regards
    Jarek
    Attached Files Attached Files

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: paste const value

    Quote Originally Posted by surferj24 View Post
    ...in column B be there should be always value a, in column b value c etc for each value from sheet1.
    It is not clear at all what you mean by this. What do "value a" and "value c" mean? How does this relate to Sheet1? It might help if you showed in your file what you want the result to look like.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    08-01-2014
    Location
    Poland
    MS-Off Ver
    14.0.7015.1000
    Posts
    14

    Re: paste const value

    Hi,

    Yes you right. That wasn't clear. Please see now attached file with result that i wnt to achieve. In sheet1 I have cells in column A with some values. i want to copy them to sheet2 but in column B for each value from sheet1 will be b, in column C value c etc. I hope this is clear.

    Thanks in advance for oyur help.
    Attached Files Attached Files

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: paste const value

    You said "copy" but I don't know if you meant to literally copy them or to be able to dynamically keep them up to date as Sheet1 changes. This example uses formulas on Sheet2 to replicate the data on Sheet1 and add a/b/c/d for non-blank entries. In this example the formulas go to row 10 but you can fill them down to as many rows as needed.

    You posted in a VBA forum but I have provided a formula solution. If this doesn't solve your problem then I guess you will need to provide a more detailed explanation of how you will use this.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    08-01-2014
    Location
    Poland
    MS-Off Ver
    14.0.7015.1000
    Posts
    14

    Re: paste const value

    Hi,

    First of all thx for your reply. Yes I also thought about formula solution but it will not work for me. Values from sheet1 should be copy to sheet2 and they should have constant values as I showed:
    in column A it should have "a" for each copy record from sheet1. In column B it should be value "b" for each record copied from sheet1 ect. However every time I open ecel file I will maintain different values in sheet1 and I want to have clear sheet2. Also function "copy" should be trigger from a button. So that's why I need macro code for this.

    BR
    Jarek

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: paste const value

    What behavior do you want after several rows have been copied, then data on Sheet1 changes? Examples: rows are all deleted then new rows are added. Data in column A of an existing row is changed.

    Do I understand correctly that you want Sheet2 to be cleared every time you open the file? What about the data on Sheet1?

    I will certainly help with the code when I get a few minutes but I still don't see how your need isn't met by formulas, other than the clearing part.

  7. #7
    Registered User
    Join Date
    08-01-2014
    Location
    Poland
    MS-Off Ver
    14.0.7015.1000
    Posts
    14

    Re: paste const value

    Yes it should be exatly as you wrote. All data in sheet1 and sheet2 will be deleted everytime after I will finish work on this file. So basically when I open file there will be no data.

  8. #8
    Registered User
    Join Date
    08-01-2014
    Location
    Poland
    MS-Off Ver
    14.0.7015.1000
    Posts
    14

    Re: paste const value

    someone has got some idea about this?

  9. #9
    Registered User
    Join Date
    08-01-2014
    Location
    Poland
    MS-Off Ver
    14.0.7015.1000
    Posts
    14

    Re: paste const value

    problem has been solved thx for your support 6StringJazzer

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: paste const value

    Glad to hear you have it solved, sorry I couldn't get back sooner.

+ 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. Can Const be defined once in one Sub?
    By oops in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-25-2007, 04:02 PM
  2. How to deal with Constants CONST
    By newbie12 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2007, 01:11 PM
  3. public const
    By jocke in forum Excel General
    Replies: 1
    Last Post: 12-06-2006, 01:17 AM
  4. public const availability?
    By lcoreyl in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-01-2006, 11:22 AM
  5. how to declare Pub Const String Array ?
    By dick in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2005, 02:05 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