copying cells from sheet 1 to various other sheets
Page 6 of 7 FirstFirst ... 4567 LastLast
Results 51 to 60 of 63

Thread: copying cells from sheet 1 to various other sheets

  1. #51
    Board Regular
    Join Date
    Aug 2019
    Posts
    80
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: copying cells from sheet 1 to various other sheets

    Hi

    Thank you for that, I will go and have a good read of that, just the last point, how do we know all data is copied across? would it tell us if any were missed?

  2. #52
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    26,732
    Post Thanks / Like
    Mentioned
    458 Post(s)
    Tagged
    45 Thread(s)

    Default Re: copying cells from sheet 1 to various other sheets

    As long as there is a value in col D then it should get copied.
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  3. #53
    Board Regular
    Join Date
    Aug 2019
    Posts
    80
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: copying cells from sheet 1 to various other sheets

    Hi

    Thank you for all your help, i have now created a button, all seems to be working.

    Regards

    Stephen

  4. #54
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    26,732
    Post Thanks / Like
    Mentioned
    458 Post(s)
    Tagged
    45 Thread(s)

    Default Re: copying cells from sheet 1 to various other sheets

    You're welcome & thanks for the feedback
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  5. #55
    Board Regular
    Join Date
    Aug 2019
    Posts
    80
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: copying cells from sheet 1 to various other sheets

    Hi again

    Just been playing around with the workbook. So we ran a few scenarios and this is what happened. We added a new record with a new company name, we clicked the macro and it worked ok, then we changed the name of the entry to an existing company and re ran the macro, it didn't update the record to anywhere and left the old entry on the new sheet?

    We also edited an existing record using Find and replace to change a company name to a new name, it created a new sheet with no records and left the existing sheet in place, it also created a blank sheet called company. The other thing is the macro I have on the master sheet was copied to all the new pages it created, but didn't assign the macro (i.e. didn't want the button copying across).

    Regards

    Stephen

  6. #56
    Board Regular
    Join Date
    Aug 2019
    Posts
    80
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: copying cells from sheet 1 to various other sheets

    Hi also noted that when you run the macro a date is shown in column M and if i try to place a filter on say line 4 and try to filter what is column G, it doesn't work?

  7. #57
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    26,732
    Post Thanks / Like
    Mentioned
    458 Post(s)
    Tagged
    45 Thread(s)

    Default Re: copying cells from sheet 1 to various other sheets

    The code needs to go in a standard module, not the sheet module.
    then we changed the name of the entry to an existing company and re ran the macro, it didn't update the record to anywhere and left the old entry on the new sheet?
    That's what I would expect to happen.

    If you are editing existing entries & want lines added & deleted accordingly, including deleting sheets, then you will need completely different code.
    In which case you will need to start a new thread & explain from the outset, EXACTLY what you need to happen & when.

    I cannot replicate a scenario where the shape used to run a macro is copied across to each new sheet.
    This will correct some of the other problems
    Code:
    Sub sbrown64()
       Dim Cl As Range
       Dim Ky As Variant
       Dim Ws As Worksheet
       Dim UsdRws As Long
       
       On Error GoTo Xit
       Application.ScreenUpdating = False
       Set Ws = Sheets(1)
       If Ws.AutoFilterMode Then Ws.AutoFilterMode = False
       UsdRws = Ws.Range("D" & Rows.Count).End(xlUp).Row
       With CreateObject("Scripting.dictionary")
          .CompareMode = vbTextCompare
          For Each Cl In Ws.Range("D5:D" & UsdRws)
             If Cl.Value <> "" Then .item(Trim(Cl.Value)) = Empty
          Next Cl
          For Each Ky In .Keys
             Ws.Range("A4:M" & UsdRws).AutoFilter 4, Ky
             Ws.Range("A4:M" & UsdRws).AutoFilter 13, ""
             If Not Evaluate("isref('" & Left(Ky, 30) & "'!A1)") Then
                Sheets.Add(, Sheets(1)).Name = Left(Ky, 30)
                Ws.Range("A1:A" & UsdRws).SpecialCells(xlVisible).EntireRow.Copy Sheets(Left(Ky, 30)).Range("A1")
                Ws.Range("M5:M" & UsdRws).SpecialCells(xlVisible).Value = Date
             Else
                On Error Resume Next
                Ws.Range("A5:A" & UsdRws).SpecialCells(xlVisible).EntireRow.Copy Sheets(Left(Ky, 30)).Range("D" & Rows.Count).End(xlUp).Offset(1, -3)
                Ws.Range("M5:M" & UsdRws).SpecialCells(xlVisible).Value = Date
                On Error GoTo Xit
             End If
          Next Ky
       End With
       Ws.AutoFilterMode = False
       Exit Sub
    Xit:
       Ws.AutoFilterMode = False
       MsgBox "The macro encountered an error" & vbLf & "Error " & Err.Number & " " & Err.Description
    End Sub
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  8. #58
    Board Regular
    Join Date
    Aug 2019
    Posts
    80
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: copying cells from sheet 1 to various other sheets

    Hi

    I have just pasted the new code and it works, with regards to editing and deleting lines/tabs i will start a new thread.

    Thank you for all your work.

    Regards

    Stephen

  9. #59
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    26,732
    Post Thanks / Like
    Mentioned
    458 Post(s)
    Tagged
    45 Thread(s)

    Default Re: copying cells from sheet 1 to various other sheets

    You're welcome & thanks for the feedback
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  10. #60
    Board Regular
    Join Date
    Aug 2019
    Posts
    80
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: copying cells from sheet 1 to various other sheets

    Hi again

    Just a quick question about this post
    I also notice that one of the company names is longer than the max allowed length for a sheet name, so I have capped it 30 characters.

    Can you point out where that code is? as is may be useful going forward? i.e. is it a case of changing the number?

    Regards

    Stephen

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •