+ Reply to Thread
Results 1 to 12 of 12

Copy paste a blocked cell in a column

  1. #1
    Registered User
    Join Date
    09-10-2023
    Location
    Italy, Milan
    MS-Off Ver
    2013
    Posts
    6

    Copy paste a blocked cell in a column

    I would like to create a column of formulas that looks like this:

    1st cell
    Please Login or Register  to view this content.
    2nd cell
    Please Login or Register  to view this content.
    3rd cell
    Please Login or Register  to view this content.
    But if I copy paste the 1st cell in the column I get this result instead:

    1st cell
    Please Login or Register  to view this content.
    2nd cell
    Please Login or Register  to view this content.
    3rd cell
    Please Login or Register  to view this content.
    How can I get the first result?

    Thank you very much

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

    Re: Copy paste a blocked cell in a column

    For your situation there is no reason to use the "$" in the formula. Use

    =A1-B1

    in row 1 and copy down.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    09-10-2023
    Location
    Italy, Milan
    MS-Off Ver
    2013
    Posts
    6

    Re: Copy paste a blocked cell in a column

    I omitted some informations.
    My formula in reality is a subtraction between the value of a cell in another excel file and the value of a cell in my current excel file.
    So, the cell looks like this:
    ='C:\Users\Username\Desktop\[AnotherExcelFile.xlsx]Foglio1'!$A$2-B2
    The reason I need A2 to not change it's because I order often the columns from A to Z or from higher cost to lower cost and I need that the formula always refers to the same cell on the other excel file.

  4. #4
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,435

    Re: Copy paste a blocked cell in a column

    If you copy down your formula $A$2 does not change and B2 changes to B3, B4 and so on (conform your requirement)
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Copy paste a blocked cell in a column

    Quote Originally Posted by prarip View Post
    I omitted some informations.
    My formula in reality is a subtraction between the value of a cell in another excel file and the value of a cell in my current excel file.
    So, the cell looks like this:
    Mi dispiace but that is completely different than your original question. This formula does not have the same problem you described in your first post.

  6. #6
    Registered User
    Join Date
    09-10-2023
    Location
    Italy, Milan
    MS-Off Ver
    2013
    Posts
    6

    Re: Copy paste a blocked cell in a column

    I'm sorry, I thought that writing it like in my first post was clearer but I created confusion.
    So, I would like to achieve this result without having to write manually every cell:

    ='C:\Users\Username\Desktop\[AnotherExcelFile.xlsx]Foglio1'!$A$1-B1
    ='C:\Users\Username\Desktop\[AnotherExcelFile.xlsx]Foglio1'!$A$2-B2
    ='C:\Users\Username\Desktop\[AnotherExcelFile.xlsx]Foglio1'!$A$3-B3
    ='C:\Users\Username\Desktop\[AnotherExcelFile.xlsx]Foglio1'!$A$4-B4
    ='C:\Users\Username\Desktop\[AnotherExcelFile.xlsx]Foglio1'!$A$5-B5
    etc.

    If I copy paste the first cell I get this result instead:

    ='C:\Users\Username\Desktop\[AnotherExcelFile.xlsx]Foglio1'!$A$1-B1
    ='C:\Users\Username\Desktop\[AnotherExcelFile.xlsx]Foglio1'!$A$1-B2
    ='C:\Users\Username\Desktop\[AnotherExcelFile.xlsx]Foglio1'!$A$1-B3
    ='C:\Users\Username\Desktop\[AnotherExcelFile.xlsx]Foglio1'!$A$1-B4
    ='C:\Users\Username\Desktop\[AnotherExcelFile.xlsx]Foglio1'!$A$1-B5

    Thank you

  7. #7
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,435

    Re: Copy paste a blocked cell in a column

    Please replace $A$1 by $A1.
    In that case if you copy down, you will get $A1, $A2, $A3 and so on.

    $A$1 is the same reference as $A1, $A$2 is the same reference as $A2 and so on.
    The only difference when copying is that they change differently.

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Copy paste a blocked cell in a column

    Change $A$1 to $A1 as HansDouwe says. If you sort the rows in AnotherExcelFile the formula in the first row will still refer to A1, second row A2, etc.

  9. #9
    Registered User
    Join Date
    09-10-2023
    Location
    Italy, Milan
    MS-Off Ver
    2013
    Posts
    6

    Re: Copy paste a blocked cell in a column

    Thank you for the answers but unfortunately it seems like there's not an easy way to achieve what I need and I'm not explaining well.

    So, in my excel file I have a list of 100 products ordered from A to Z.
    In 'AnotherExcelFile' I have the same list of 100 products ordered from A to Z, the difference it is only that they can have different prices (price is in column B in my excel file and in column A in 'AnotherExcelFile').
    So, the product in the first row in my excel file corresponds exactly to the same product in the first row in 'AnotherExcelFile'.
    I don't want to compare the price of 2 different products, I want to compare the price of the same product.

    The problem comes because in my excel file I need to change the order often for various parameters.
    But if I change the order in my excel file my products price doesn't refer anymore to the corresponding same product price in 'AnotherExcelFile'.

    So, if I copy paste "='C:\Users\Username\Desktop\[AnotherExcelFile.xlsx]Foglio1'!$A1-B1" my columns will look like this:

    ='C:\Users\Username\Desktop\[AnotherExcelFile.xlsx]Foglio1'!$A1-B1
    ='C:\Users\Username\Desktop\[AnotherExcelFile.xlsx]Foglio1'!$A2-B2
    ='C:\Users\Username\Desktop\[AnotherExcelFile.xlsx]Foglio1'!$A3-B3

    But if I change the order in my excel file from Z to A for example, since the order in AnotherExcelFile is from A to Z I will get the difference in price between 2 products that are not the same product.
    I want to compare the change in price for apples, not between apples and bananas.

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

    Re: Copy paste a blocked cell in a column

    Let me try to rephrase what you want to confirm I understand this:

    • You have a list of products in file A with a price for each product
    • You have a list of the same products in file B with a price for each product
    • The price for a given product can be different in the two files
    • In file A you want to do a comparison of the two prices
    • You want to be able to sort the product list in file B arbitrarily and still be able to reference the corresponding products from file A.


    I am going to suggest that your approach of trying to find a formula in file A that uses a row number that will always refer to the correct product in file B when the row changes in column B is not going to work.

    Another approach is to use the product to do a lookup of the price. Unfortunately the VLOOKUP command (XLOOKUP in newer versions of Excel) will not work on a closed workbook. I am going to suggest you create a mirror sheet in file A that references the data in file B. Then you can use VLOOKUP on the mirror sheet to retrieve the price.

    1. Create a new sheet in file A. Name it Mirror. Put this formula in cell A1:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Instead of B use the actual last column of data you want to reference, and obviously, use the real file name.
    Copy this formula to the right for as many columns as needed, and down for the maximum number of products you expect to ever have.

    Close File B if it is open. The data in sheet Mirror should still be there.

    2. You have not described the layout of your data in either file, so I am going to have to make assumptions. You may have to change the column references here.

    In file B assume that Product is in column A, price is in column B. This will also be true in file A, sheet Mirror.

    In File A assume the sheet containing the product list is in Sheet1, and also the product is in column A and price is in column B.

    In File A Sheet1, put the following formula in C1 to get the price of the product in the row from file B:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Fill down for as many rows as needed.

    If you have any problem implementing this, attach samples of File A and File B with any private data removed or disguised and I can do it for you.

  11. #11
    Registered User
    Join Date
    09-10-2023
    Location
    Italy, Milan
    MS-Off Ver
    2013
    Posts
    6

    Re: Copy paste a blocked cell in a column

    Thank you so much for your help.
    I've tried again your first formulas without the '$' and it is working properly.
    In fact if I change the order in the first excel file the reference to the cells in the other excel doesn't change.
    I feel ashamed to have wasted your time, next time I will do more checks before replying to your answers.
    Have a good day!

  12. #12
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,435

    Re: Copy paste a blocked cell in a column

    You are Welcome!

    Thanks for the feedback and glad to have helped.

    If you haven't already, please consider adding reputation to all helpers you think they deserve.
    In that case please click * Add Reputation left below their answers.

+ 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. copy Formula & paste in same column next cell when previous column is not blank
    By sanjuss2 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-03-2020, 01:59 AM
  2. Copy Paste Issue Merge Cell & Paste Values other Column
    By majidsiddique in forum Excel General
    Replies: 12
    Last Post: 04-28-2020, 01:07 AM
  3. [SOLVED] VB Code to copy paste data from column to another column based on content of cell
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-28-2019, 08:50 PM
  4. Copy data and paste to another column incrementing that column to next empty cell
    By edens2021 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2015, 11:43 AM
  5. [SOLVED] Window gets blocked with copy paste
    By pezalmendra in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-05-2013, 01:48 PM
  6. Vba - find next empty column, insert column, copy paste values & copy paste formulas
    By DoodlesMama in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-20-2012, 12:43 PM
  7. [SOLVED] Copy and Paste a specific Column to a Column that's heading matches a particular cell
    By Rexmond in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-17-2012, 12:29 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