Copying all formatting to another sheet in VBA, removes number formatting on original sheet
up vote
0
down vote
favorite
Having an issue when I paste across formatting from a template to another sheet holding values and text imported from a closed book.
The template sheet number formats change from custom to date for seemingly no apparent reason. Any help would be appreciated. Thanks
Dim WS As Worksheet
Set WS = ThisWorkbook.Worksheets.Add(After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count), Type:=xlWorksheet)
WS.Name = TextBox1.Value
Set WshNew = ThisWorkbook.Worksheets("Template_NewDCF")
Set WshOld = ThisWorkbook.Worksheets("Template_OldDCF")
Set wb = ActiveWorkbook
GetData NameTextBox.Value, "DCF", "A1:DD67", Sheets(TextBox1.Value).Range("A1:DD67"), False, False
If ComboBox1 = "Old Template" Then
WshOld.Cells.Copy
With WS.Cells
.PasteSpecial Paste:=xlPasteFormats 'Source format is pasted.
.PasteSpecial Paste:=xlPasteComments 'Comments are pasted.
.PasteSpecial Paste:=xlPasteValidation 'Validations are pasted.
Application.CutCopyMode = False
Application.GoTo .Cells(1), 1
ActiveWindow.DisplayGridlines = False
WS.Cells(2, 15) = WshNew.Cells(2, 2)
End With
excel vba formatting
add a comment |
up vote
0
down vote
favorite
Having an issue when I paste across formatting from a template to another sheet holding values and text imported from a closed book.
The template sheet number formats change from custom to date for seemingly no apparent reason. Any help would be appreciated. Thanks
Dim WS As Worksheet
Set WS = ThisWorkbook.Worksheets.Add(After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count), Type:=xlWorksheet)
WS.Name = TextBox1.Value
Set WshNew = ThisWorkbook.Worksheets("Template_NewDCF")
Set WshOld = ThisWorkbook.Worksheets("Template_OldDCF")
Set wb = ActiveWorkbook
GetData NameTextBox.Value, "DCF", "A1:DD67", Sheets(TextBox1.Value).Range("A1:DD67"), False, False
If ComboBox1 = "Old Template" Then
WshOld.Cells.Copy
With WS.Cells
.PasteSpecial Paste:=xlPasteFormats 'Source format is pasted.
.PasteSpecial Paste:=xlPasteComments 'Comments are pasted.
.PasteSpecial Paste:=xlPasteValidation 'Validations are pasted.
Application.CutCopyMode = False
Application.GoTo .Cells(1), 1
ActiveWindow.DisplayGridlines = False
WS.Cells(2, 15) = WshNew.Cells(2, 2)
End With
excel vba formatting
Could you provide a Minimal, Complete, and Verifiable example with test data so we can reproduce the issue?
– Pᴇʜ
Nov 19 at 8:40
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Having an issue when I paste across formatting from a template to another sheet holding values and text imported from a closed book.
The template sheet number formats change from custom to date for seemingly no apparent reason. Any help would be appreciated. Thanks
Dim WS As Worksheet
Set WS = ThisWorkbook.Worksheets.Add(After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count), Type:=xlWorksheet)
WS.Name = TextBox1.Value
Set WshNew = ThisWorkbook.Worksheets("Template_NewDCF")
Set WshOld = ThisWorkbook.Worksheets("Template_OldDCF")
Set wb = ActiveWorkbook
GetData NameTextBox.Value, "DCF", "A1:DD67", Sheets(TextBox1.Value).Range("A1:DD67"), False, False
If ComboBox1 = "Old Template" Then
WshOld.Cells.Copy
With WS.Cells
.PasteSpecial Paste:=xlPasteFormats 'Source format is pasted.
.PasteSpecial Paste:=xlPasteComments 'Comments are pasted.
.PasteSpecial Paste:=xlPasteValidation 'Validations are pasted.
Application.CutCopyMode = False
Application.GoTo .Cells(1), 1
ActiveWindow.DisplayGridlines = False
WS.Cells(2, 15) = WshNew.Cells(2, 2)
End With
excel vba formatting
Having an issue when I paste across formatting from a template to another sheet holding values and text imported from a closed book.
The template sheet number formats change from custom to date for seemingly no apparent reason. Any help would be appreciated. Thanks
Dim WS As Worksheet
Set WS = ThisWorkbook.Worksheets.Add(After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count), Type:=xlWorksheet)
WS.Name = TextBox1.Value
Set WshNew = ThisWorkbook.Worksheets("Template_NewDCF")
Set WshOld = ThisWorkbook.Worksheets("Template_OldDCF")
Set wb = ActiveWorkbook
GetData NameTextBox.Value, "DCF", "A1:DD67", Sheets(TextBox1.Value).Range("A1:DD67"), False, False
If ComboBox1 = "Old Template" Then
WshOld.Cells.Copy
With WS.Cells
.PasteSpecial Paste:=xlPasteFormats 'Source format is pasted.
.PasteSpecial Paste:=xlPasteComments 'Comments are pasted.
.PasteSpecial Paste:=xlPasteValidation 'Validations are pasted.
Application.CutCopyMode = False
Application.GoTo .Cells(1), 1
ActiveWindow.DisplayGridlines = False
WS.Cells(2, 15) = WshNew.Cells(2, 2)
End With
excel vba formatting
excel vba formatting
asked Nov 19 at 7:03
Adam Calvetti
1
1
Could you provide a Minimal, Complete, and Verifiable example with test data so we can reproduce the issue?
– Pᴇʜ
Nov 19 at 8:40
add a comment |
Could you provide a Minimal, Complete, and Verifiable example with test data so we can reproduce the issue?
– Pᴇʜ
Nov 19 at 8:40
Could you provide a Minimal, Complete, and Verifiable example with test data so we can reproduce the issue?
– Pᴇʜ
Nov 19 at 8:40
Could you provide a Minimal, Complete, and Verifiable example with test data so we can reproduce the issue?
– Pᴇʜ
Nov 19 at 8:40
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53369761%2fcopying-all-formatting-to-another-sheet-in-vba-removes-number-formatting-on-ori%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Could you provide a Minimal, Complete, and Verifiable example with test data so we can reproduce the issue?
– Pᴇʜ
Nov 19 at 8:40