+ Reply to Thread
Results 1 to 9 of 9

Using a formula to copy data from a row if a cell has certain data.

  1. #1
    Registered User
    Join Date
    01-15-2016
    Location
    England
    MS-Off Ver
    Version 2312 Build 16.0.17126.20132) 64-bit
    Posts
    14

    Using a formula to copy data from a row if a cell has certain data.

    Hey all, Im new at this and am not very good with VBA yet, so was hopping for a formula? I can do a VBA if its easier.

    What I want to do is find any Cell in coloumn AC that contains the value "1",
    Then copy certain cells from that row in sheet "Trafford MC" to "Sheet 2".

    I am having no luck. please help.

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,077

    Re: Using a formula to copy data from a row if a cell has certain data.

    Cells can't copy to other cells, you have to use VBA.
    You can, however, use formulas to set cell values dependant on other cells.

    What "certain cells" do you want to copy?

    You might be better off posting a spreadsheet.
    Attach a sample spreadsheet with expected results, remove any sensitive data.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Using a formula to copy data from a row if a cell has certain data.

    I am not getting exactly what you need.
    Still check the attached file.
    It may help!!
    Attached Files Attached Files
    Happy to Help

    How to upload excel workbooks at this forum - http://www.excelforum.com/the-water-...his-forum.html

    "I don't get things easily, so please be precise and elaborate"

    If someone's post has helped you, thank by clicking on "Add Reputation" below the post.
    If your query is resolved please mark the thread as "Solved" from the "Thread Tools" above.

    Sourabh

  4. #4
    Registered User
    Join Date
    01-15-2016
    Location
    England
    MS-Off Ver
    Version 2312 Build 16.0.17126.20132) 64-bit
    Posts
    14

    Re: Using a formula to copy data from a row if a cell has certain data.

    Ok VBA it is, What I want to do is if column AC of Sheet(Trafford MC) has value of 1, I want columns, B,F,H,S and Z all to be copied over to Sheet2. Im just struggling to get it. Ive seen many examples but cant seem transpose it into mine.

  5. #5
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,077

    Re: Using a formula to copy data from a row if a cell has certain data.

    If columns B F H S and Z are blank create a formula in each column

    in 'Trafford MC'!B1
    =IF('Trafford MC'!AC1=1,'Trafford MC'!B1,"")
    in 'Trafford MC'!F1
    =IF('Trafford MC'!AC1=1,'Trafford MC'!F1,"")
    in 'Trafford MC'!H1
    =IF('Trafford MC'!AC1=1,'Trafford MC'!H1,"")
    in 'Trafford MC'!S1
    =IF('Trafford MC'!AC1=1,'Trafford MC'!S1,"")
    in 'Trafford MC'!Z1
    =IF('Trafford MC'!AC1=1,'Trafford MC'!Z1,"")

    and copy down the columns
    Last edited by Special-K; 01-21-2016 at 11:32 AM.

  6. #6
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Using a formula to copy data from a row if a cell has certain data.

    Can you please be more specific?

    1. Do you only want a particular value to be searched i.e. 1 or there could be several values?
    2. Where do you want the values from column B,F,H,S and Z to be pasted in sheet 2?

  7. #7
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,077

    Re: Using a formula to copy data from a row if a cell has certain data.

    Or for VBA try (untested)

    Sub K1()
    Lastrow = Worksheets("Trafford MC").Cells(Rows.Count, "AC").End(xlUp).Row
    For i =1 to Lastrow
    If Worksheets("Trafford MC").Cells(i, "AC")=1
    Worksheets("Sheet2").Cells(i, 2)=Worksheets("Trafford MC").Cells(i, 2)
    Worksheets("Sheet2").Cells(i, 6)=Worksheets("Trafford MC").Cells(i, 6)
    Worksheets("Sheet2").Cells(i, 8)=Worksheets("Trafford MC").Cells(i, 8)
    Worksheets("Sheet2").Cells(i, 19)=Worksheets("Trafford MC").Cells(i, 19)
    Worksheets("Sheet2").Cells(i, 26)=Worksheets("Trafford MC").Cells(i, 26)
    Next i
    End Sub

  8. #8
    Registered User
    Join Date
    01-15-2016
    Location
    England
    MS-Off Ver
    Version 2312 Build 16.0.17126.20132) 64-bit
    Posts
    14

    Re: Using a formula to copy data from a row if a cell has certain data.

    Ok sorry here is a quick example of what I want. hmm... I cant seem to upload a example document.. But if you can imagine that Trafford MC is just full of things like company name etc. The value in AC will either be 1 or empty (" "). So if there is a 1 I want it to copy the as mentioned above columns to copy data to Sheet 2. If I can get this file to upload ill send it. As it stand its just constantly spinning.

  9. #9
    Registered User
    Join Date
    01-15-2016
    Location
    England
    MS-Off Ver
    Version 2312 Build 16.0.17126.20132) 64-bit
    Posts
    14

    Re: Using a formula to copy data from a row if a cell has certain data.

    If Worksheets("Trafford MC").Cells(i, "AC")=1

    This one line comes up red. Not sure why.

+ 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. Replies: 8
    Last Post: 12-05-2021, 03:25 PM
  2. [SOLVED] Copy Formula Down Till No Data In Cell
    By scarlettw123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-21-2015, 12:43 PM
  3. Replies: 6
    Last Post: 10-03-2014, 12:18 PM
  4. [SOLVED] Formula Needed to copy data from a cell based on data entered into another cell
    By excelteam777 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-10-2013, 03:16 AM
  5. [SOLVED] Formula to copy data from one cell to another
    By Angnz in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-16-2013, 08:56 AM
  6. [SOLVED] Copy data with 4 cell interval and copy range of data like vlookup with structured output
    By Daydreams in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-23-2013, 04:08 AM
  7. how do i copy just the data and not the formula in a cell?
    By Holden Caulfield in forum Excel General
    Replies: 11
    Last Post: 03-10-2006, 05:20 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