Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 395
Default VBA copy 'corrupts' font selection (XL2003)

I have raw data on Sheet3, with the entire sheet formatted in Times New Roman.

I have a form on Sheet1 where I copy sections of data from Sheet3 in a
desired order. I also took Sheet1, selected the whole sheet, and formatted in
TNR

Then I run the code below; all data that is copied over from Sheet3 keeps
getting pasted in Arial format!

Any ideas on what would cause this? I'd prefer to fix the root cause, rather
than "band-aid" it by just forcing a reapplication of the desired font after
all records are pasted.

Thank you,
Keith

Private Sub Worksheet_Change(ByVal Target As Range)

Sheet1.Unprotect "ABC"
Application.Calculation = xlCalculationManual
Application.EnableEvents = False

If Target.Rows.Count = 1 And Target.Columns.Count = 1 Then
If Target = Sheet1.Range("F1") Then

SelectedOwner = Target.Value

LastSourceRow = lastRow(Sheet3)
PasteRow = 6

Sheet1.Rows("7:100").Select
Selection.EntireRow.Hidden = False

Sheet1.Range("A7:K100").Clear

For I = 2 To LastSourceRow
If Sheet3.Range("AF" & I).Value = SelectedOwner Then
PasteRow = PasteRow + 1
Sheet1.Range("A" & PasteRow).Value = Sheet3.Range("A" &
I).Value
Sheet1.Range("B" & PasteRow).Value = Sheet3.Range("X" &
I).Value
Sheet1.Range("C" & PasteRow).Value = Sheet3.Range("Y" &
I).Value
Sheet1.Range("D" & PasteRow).Value = Sheet3.Range("Z" &
I).Value
Sheet1.Range("E" & PasteRow).Value = Sheet3.Range("AA" &
I).Value
Sheet1.Range("F" & PasteRow).Value = Sheet3.Range("U" &
I).Value
Sheet1.Range("G" & PasteRow).Value = Sheet3.Range("B" &
I).Value
Sheet1.Range("H" & PasteRow).Value = Sheet3.Range("C" &
I).Value
Sheet1.Range("I" & PasteRow).Value = Sheet3.Range("E" &
I).Value
Sheet1.Range("J" & PasteRow).Value = Sheet3.Range("F" &
I).Value
Sheet1.Range("K" & PasteRow).Value = Sheet3.Range("G" &
I).Value
End If
Next

End If
End If
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic

Sheet1.Rows((PasteRow + 1) & ":100").Select
Selection.EntireRow.Hidden = True
Sheet1.Range("L7").Select

Sheet1.Protect "ABC"


End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default VBA copy 'corrupts' font selection (XL2003)

I had this issue also once. When you use the Value property just the value
come over from Sheet3 to Sheet1. Thus if you have Arial font in Sheet1 the
cell contents will take on Arial font, kinda like SpecialPaste. Use the Text
property instead. Hope this helps! If so, let me know, click "YES" below.

Sheet1.Range("A" & PasteRow).Value = Sheet3.Range("A" & I).Text

--
Cheers,
Ryan


"ker_01" wrote:

I have raw data on Sheet3, with the entire sheet formatted in Times New Roman.

I have a form on Sheet1 where I copy sections of data from Sheet3 in a
desired order. I also took Sheet1, selected the whole sheet, and formatted in
TNR

Then I run the code below; all data that is copied over from Sheet3 keeps
getting pasted in Arial format!

Any ideas on what would cause this? I'd prefer to fix the root cause, rather
than "band-aid" it by just forcing a reapplication of the desired font after
all records are pasted.

Thank you,
Keith

Private Sub Worksheet_Change(ByVal Target As Range)

Sheet1.Unprotect "ABC"
Application.Calculation = xlCalculationManual
Application.EnableEvents = False

If Target.Rows.Count = 1 And Target.Columns.Count = 1 Then
If Target = Sheet1.Range("F1") Then

SelectedOwner = Target.Value

LastSourceRow = lastRow(Sheet3)
PasteRow = 6

Sheet1.Rows("7:100").Select
Selection.EntireRow.Hidden = False

Sheet1.Range("A7:K100").Clear

For I = 2 To LastSourceRow
If Sheet3.Range("AF" & I).Value = SelectedOwner Then
PasteRow = PasteRow + 1
Sheet1.Range("A" & PasteRow).Value = Sheet3.Range("A" &
I).Value
Sheet1.Range("B" & PasteRow).Value = Sheet3.Range("X" &
I).Value
Sheet1.Range("C" & PasteRow).Value = Sheet3.Range("Y" &
I).Value
Sheet1.Range("D" & PasteRow).Value = Sheet3.Range("Z" &
I).Value
Sheet1.Range("E" & PasteRow).Value = Sheet3.Range("AA" &
I).Value
Sheet1.Range("F" & PasteRow).Value = Sheet3.Range("U" &
I).Value
Sheet1.Range("G" & PasteRow).Value = Sheet3.Range("B" &
I).Value
Sheet1.Range("H" & PasteRow).Value = Sheet3.Range("C" &
I).Value
Sheet1.Range("I" & PasteRow).Value = Sheet3.Range("E" &
I).Value
Sheet1.Range("J" & PasteRow).Value = Sheet3.Range("F" &
I).Value
Sheet1.Range("K" & PasteRow).Value = Sheet3.Range("G" &
I).Value
End If
Next

End If
End If
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic

Sheet1.Rows((PasteRow + 1) & ":100").Select
Selection.EntireRow.Hidden = True
Sheet1.Range("L7").Select

Sheet1.Protect "ABC"


End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default VBA copy 'corrupts' font selection (XL2003)

Would .value2 work any better?
--
HTH,

Barb Reinhardt



"Ryan H" wrote:

I had this issue also once. When you use the Value property just the value
come over from Sheet3 to Sheet1. Thus if you have Arial font in Sheet1 the
cell contents will take on Arial font, kinda like SpecialPaste. Use the Text
property instead. Hope this helps! If so, let me know, click "YES" below.

Sheet1.Range("A" & PasteRow).Value = Sheet3.Range("A" & I).Text

--
Cheers,
Ryan


"ker_01" wrote:

I have raw data on Sheet3, with the entire sheet formatted in Times New Roman.

I have a form on Sheet1 where I copy sections of data from Sheet3 in a
desired order. I also took Sheet1, selected the whole sheet, and formatted in
TNR

Then I run the code below; all data that is copied over from Sheet3 keeps
getting pasted in Arial format!

Any ideas on what would cause this? I'd prefer to fix the root cause, rather
than "band-aid" it by just forcing a reapplication of the desired font after
all records are pasted.

Thank you,
Keith

Private Sub Worksheet_Change(ByVal Target As Range)

Sheet1.Unprotect "ABC"
Application.Calculation = xlCalculationManual
Application.EnableEvents = False

If Target.Rows.Count = 1 And Target.Columns.Count = 1 Then
If Target = Sheet1.Range("F1") Then

SelectedOwner = Target.Value

LastSourceRow = lastRow(Sheet3)
PasteRow = 6

Sheet1.Rows("7:100").Select
Selection.EntireRow.Hidden = False

Sheet1.Range("A7:K100").Clear

For I = 2 To LastSourceRow
If Sheet3.Range("AF" & I).Value = SelectedOwner Then
PasteRow = PasteRow + 1
Sheet1.Range("A" & PasteRow).Value = Sheet3.Range("A" &
I).Value
Sheet1.Range("B" & PasteRow).Value = Sheet3.Range("X" &
I).Value
Sheet1.Range("C" & PasteRow).Value = Sheet3.Range("Y" &
I).Value
Sheet1.Range("D" & PasteRow).Value = Sheet3.Range("Z" &
I).Value
Sheet1.Range("E" & PasteRow).Value = Sheet3.Range("AA" &
I).Value
Sheet1.Range("F" & PasteRow).Value = Sheet3.Range("U" &
I).Value
Sheet1.Range("G" & PasteRow).Value = Sheet3.Range("B" &
I).Value
Sheet1.Range("H" & PasteRow).Value = Sheet3.Range("C" &
I).Value
Sheet1.Range("I" & PasteRow).Value = Sheet3.Range("E" &
I).Value
Sheet1.Range("J" & PasteRow).Value = Sheet3.Range("F" &
I).Value
Sheet1.Range("K" & PasteRow).Value = Sheet3.Range("G" &
I).Value
End If
Next

End If
End If
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic

Sheet1.Rows((PasteRow + 1) & ":100").Select
Selection.EntireRow.Hidden = True
Sheet1.Range("L7").Select

Sheet1.Protect "ABC"


End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Copy, Paste not working properly, corrupts file Marvin B Excel Discussion (Misc queries) 1 March 3rd 09 04:21 PM
Copy Selection - Paste Selection - Delete Selection Uninvisible Excel Programming 2 October 25th 07 01:31 PM
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
Worksheet Copy fails (xl2003) Darren Hill[_4_] Excel Programming 7 April 1st 07 10:33 PM
Weird range selection issue XL2003- help please! KR Excel Programming 3 April 28th 06 08:27 PM


All times are GMT +1. The time now is 11:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"