ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Formating lost when cut and insert (https://www.excelbanter.com/excel-programming/421649-formating-lost-when-cut-insert.html)

Greg Snidow

Formating lost when cut and insert
 
Greetings all. I have a workbook with one sheet for every month of the year.
I often have to cut a row out of one sheet and insert it into another sheet.
I have conditional formatting that is the same on each sheet, that I used
formatconditional formatting to enter. The problem is that every time I
move a row to a different sheet, the conditional formatting is lost. Is
there a way I can add the contitional formatting to the macro that moves the
row? The macro, when run, cuts the highlighted row, inserts it into the new
sheet, then resorts the new sheet and puts the value lists back in the proper
place. Can I add code to set conditional formatting in a macro? Thank you.

Per Jessen

Formating lost when cut and insert
 
Hi

Copy the formatting from another cell with the desired formatting:

Sub test()
TargetRow = 5
Rows(1).Copy ' Row with desired formatting
Rows(TargetRow).PasteSpecial Paste:=xlFormats, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
End Sub


Regards,
Per

"Greg Snidow" skrev i meddelelsen
...
Greetings all. I have a workbook with one sheet for every month of the
year.
I often have to cut a row out of one sheet and insert it into another
sheet.
I have conditional formatting that is the same on each sheet, that I used
formatconditional formatting to enter. The problem is that every time I
move a row to a different sheet, the conditional formatting is lost. Is
there a way I can add the contitional formatting to the macro that moves
the
row? The macro, when run, cuts the highlighted row, inserts it into the
new
sheet, then resorts the new sheet and puts the value lists back in the
proper
place. Can I add code to set conditional formatting in a macro? Thank
you.



Greg Snidow

Formating lost when cut and insert
 
Thanks Per, I don't know why I did not think of that, but it seems to work.
Thanks, and have a great holiday.

"Per Jessen" wrote:

Hi

Copy the formatting from another cell with the desired formatting:

Sub test()
TargetRow = 5
Rows(1).Copy ' Row with desired formatting
Rows(TargetRow).PasteSpecial Paste:=xlFormats, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
End Sub


Regards,
Per

"Greg Snidow" skrev i meddelelsen
...
Greetings all. I have a workbook with one sheet for every month of the
year.
I often have to cut a row out of one sheet and insert it into another
sheet.
I have conditional formatting that is the same on each sheet, that I used
formatconditional formatting to enter. The problem is that every time I
move a row to a different sheet, the conditional formatting is lost. Is
there a way I can add the contitional formatting to the macro that moves
the
row? The macro, when run, cuts the highlighted row, inserts it into the
new
sheet, then resorts the new sheet and puts the value lists back in the
proper
place. Can I add code to set conditional formatting in a macro? Thank
you.





All times are GMT +1. The time now is 06:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com