Macro needs help with Copy

Folks,
This is the code I'm using
Sub InsertNewYearConsolidated()
    Dim ws As Worksheet, rw As Long
    Set ws = Worksheets("Consolidated")
    ws.Select
    
    'Insert 12 rows above Totals and the spacer row
    rw = ws.Range("A:A").Find("Totals").Row
    ws.Rows(((rw - 1) & ":" & (rw + 10))).Insert Shift:=xlDown
    
    'copy the format from the first 12 rows (6 to 17)
    ws.Range("A6:U17").Copy
    ws.Range("A" & (rw - 1)).Select
    Selection.PasteSpecial Paste:=xlPasteFormats
   Ws.Range(“A6:A17”).Copy
   Selection.PasteSpecial Paste:=xlPasteValues    
   Application.CutCopyMode = False

    Range("A1").Select
End Sub

Open in new window

In adding lines 14 and 15 I'm getting this:
Wrong fillNot exactly what I am needing which is this:
correct fill
Frank FreeseAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

duncanb7Commented:
Could you send us your Excel workbook with that macro so that we can run it
at our side that assist to solve the issue quickly

Duncan
0
Frank FreeseAuthor Commented:
Sure no problem. It is attached; On the Cost Allocation Main worksheet you will find a command button with the macro
named InsertNew YearConsolidated. I added to the original code
    ws.Range("A6:A17").Copy
    Selection.PasteSpecial Paste:=xlPasteValues

Open in new window

The rest of the code is correct.
Project-Cost-Allocation-Revised1.xlsm
0
duncanb7Commented:
Sorry, ignore the previous writing, I could open it now and run it

Duncan
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

duncanb7Commented:
What is the result you want on Consolidated sheet after macro running. Could you put the data into sheet and send us in other file ?

Duncan
0
duncanb7Commented:
Please try this code

Duncan
Sub InsertNewYearConsolidated()
    Dim ws As Worksheet, rw As Long
    Set ws = Worksheets("Consolidated")
    ws.Select
    
    'Insert 12 rows above Totals and the spacer row
    rw = ws.Range("A:A").Find("Totals").Row
    ws.Rows(((rw - 1) & ":" & (rw + 10))).Insert Shift:=xlDown
   ' ws.Range("B" & (rw - 1) & ":" & "B" & (rw + 10)).NumberFormat = "dd/mm/yyyy"
    'copy the format from the first 12 rows (6 to 17)
  '  ws.Range("A6:U17").Copy
    ws.Range("A" & (rw - 1) & ":" & "A" & (rw + 10)).Select
    ws.Range("A6:A17").Copy
   Selection.PasteSpecial Paste:=xlPasteValues
 
   
    Application.CutCopyMode = False

    Range("A1").Select
End Sub

Open in new window

0
duncanb7Commented:
Please see the attached file, and you delete the rows below row17, and then re-run marco

Duncan
junk2.xlsm
0
Frank FreeseAuthor Commented:
Duncan,
This code maintains the row and column formatting needed.
Sub InsertNewYearConsolidated()
    Dim ws As Worksheet, rw As Long
    Set ws = Worksheets("Consolidated")
    ws.Select
    
    'Insert 12 rows above Totals and the spacer row
    rw = ws.Range("A:A").Find("Totals").Row
    ws.Rows(((rw - 1) & ":" & (rw + 10))).Insert Shift:=xlDown
    
    'copy the format from the first 12 rows (6 to 17)
    ws.Range("A6:U17").Copy
    ws.Range("A" & (rw - 1)).Select
    Selection.PasteSpecial Paste:=xlPasteFormats
   Application.CutCopyMode = False

    Range("A1").Select
End Sub

Open in new window

From that I get this
 correct fillThe above is correct.
What I am getting from junk2.xlsm looks like this:
incorrect fill
You give me the months Jan - Dec but not the formatting. When I'm adding to the worksheet I am also adding the months Jan - Dec in A18:A29. That's what's missing from the code snippet provided above --- adding Jan - Dec is my objective. I'm having some issues adding the year but I may post another question if I need to..
0
duncanb7Commented:
based on my attached example to solve the rest of your issue

have a nice day

Duncan
0
Frank FreeseAuthor Commented:
I'm not sure I understand your response. Are you saying that you have provided a solution?
thanks
Frank
0
Frank FreeseAuthor Commented:
Actually, I was able to resolve this myself today. It truly was not as difficult of a fix that I though.
Thanks for your support
0
duncanb7Commented:
I have already done the code for the image at  http://filedb.experts-exchange.com/incoming/2014/07_w29/861307/correctfill.jpg

Is it right ?

Duncan
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Frank FreeseAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for fh_freese's comment #a40203317

for the following reason:

Duncan left me with the impression he had offered a solution, which unfortunately, was not the case. So I spent more time with the problem and saw how to do it myself.
I simply added this snippet:
    Range("A6:A17").Select
    Selection.Copy
    Range("A18:A29").Select
problem solved
0
duncanb7Commented:
I'd also spent  a lot time to read your question in detail  and made the code even that is not matched to your need finally.

Anyway, glad to see you have solved your problem

Have a nice day

Duncan
0
Frank FreeseAuthor Commented:
Duncan,
I tried everything you posted and displayed the results. Yes, you did add the months but the rest of the formatting was something I could not use. I closed this question when I discovered that all the new code that was needed was:
    Range("A6:A17").Select
    Selection.Copy
    Range("A18:A29").Select

Right before:
Range("A1").Select
this last line of code I had.
I personally don't collect points and if there was some way to give you partial I truly would
0
Frank FreeseAuthor Commented:
Duncan,
You are good man and dedicated to helping us. I'll have more posts of this problem for sure - my client is taking me to on a Star Trek adventure - To boldly go....
Again,
Accept my grateful thanks and appreciation
Frank
0
Frank FreeseAuthor Commented:
Duncan work on this and there is a value. I'm going to give him the points
0
Frank FreeseAuthor Commented:
Thanks Duncan!
0
duncanb7Commented:
Thanks for your points

Have a nice day

Duncan
0
Frank FreeseAuthor Commented:
My pleasure. You have a great day also.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.