Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Macro Functionality

Gien the following macro:
Option Explicit
Sub mastertest2()
Dim rSource As Range
Dim rCell As Range
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim wks As Worksheet

For Each wks In Worksheets(Array("SBX WORK SHEET"))
With wks
FirstRow = 4
LastRow = .Cells(.Rows.Count, 4).End(xlUp).Row
End With

For iRow = LastRow To FirstRow Step -1
Set rCell = wks.Cells(iRow, 4)
With rCell
If Not IsEmpty(.Value) Then
If IsNumeric(.Value) Then
Worksheets("SBX COST SHEET").Rows(17).Insert
..EntireRow.Copy
Worksheets("SBX COST SHEET").Range("a17") _
..PasteSpecial Paste:=xlPasteValues
End If
End If
End With
Next iRow
Next wks
End Sub

Why does this macro copy the contecnts correctly but it copies them bolded,
centered and no text wrap to the destination?
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Macro Functionality

Because you are paste/special/values, the values in the destination cells
will be updated, but the formats will be the same as they were before the
paste.

(the paste will not change them)
--
Gary''s Student - gsnu200811


"Jerry Foley" wrote:

Gien the following macro:
Option Explicit
Sub mastertest2()
Dim rSource As Range
Dim rCell As Range
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim wks As Worksheet

For Each wks In Worksheets(Array("SBX WORK SHEET"))
With wks
FirstRow = 4
LastRow = .Cells(.Rows.Count, 4).End(xlUp).Row
End With

For iRow = LastRow To FirstRow Step -1
Set rCell = wks.Cells(iRow, 4)
With rCell
If Not IsEmpty(.Value) Then
If IsNumeric(.Value) Then
Worksheets("SBX COST SHEET").Rows(17).Insert
.EntireRow.Copy
Worksheets("SBX COST SHEET").Range("a17") _
.PasteSpecial Paste:=xlPasteValues
End If
End If
End With
Next iRow
Next wks
End Sub

Why does this macro copy the contecnts correctly but it copies them bolded,
centered and no text wrap to the destination?
Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Macro Functionality

You are pasting the values use PasteSpecial with the values option. This is
not copying the formating. Your code is inserting a new row 17. This new
row will have the same formating as Row 16.

"Jerry Foley" wrote:

Gien the following macro:
Option Explicit
Sub mastertest2()
Dim rSource As Range
Dim rCell As Range
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim wks As Worksheet

For Each wks In Worksheets(Array("SBX WORK SHEET"))
With wks
FirstRow = 4
LastRow = .Cells(.Rows.Count, 4).End(xlUp).Row
End With

For iRow = LastRow To FirstRow Step -1
Set rCell = wks.Cells(iRow, 4)
With rCell
If Not IsEmpty(.Value) Then
If IsNumeric(.Value) Then
Worksheets("SBX COST SHEET").Rows(17).Insert
.EntireRow.Copy
Worksheets("SBX COST SHEET").Range("a17") _
.PasteSpecial Paste:=xlPasteValues
End If
End If
End With
Next iRow
Next wks
End Sub

Why does this macro copy the contecnts correctly but it copies them bolded,
centered and no text wrap to the destination?
Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Macro Functionality

Thanks,
What should be changed to reflect the same formatting and values as the main
sheet?

"Joel" wrote:

You are pasting the values use PasteSpecial with the values option. This is
not copying the formating. Your code is inserting a new row 17. This new
row will have the same formating as Row 16.

"Jerry Foley" wrote:

Gien the following macro:
Option Explicit
Sub mastertest2()
Dim rSource As Range
Dim rCell As Range
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim wks As Worksheet

For Each wks In Worksheets(Array("SBX WORK SHEET"))
With wks
FirstRow = 4
LastRow = .Cells(.Rows.Count, 4).End(xlUp).Row
End With

For iRow = LastRow To FirstRow Step -1
Set rCell = wks.Cells(iRow, 4)
With rCell
If Not IsEmpty(.Value) Then
If IsNumeric(.Value) Then
Worksheets("SBX COST SHEET").Rows(17).Insert
.EntireRow.Copy
Worksheets("SBX COST SHEET").Range("a17") _
.PasteSpecial Paste:=xlPasteValues
End If
End If
End With
Next iRow
Next wks
End Sub

Why does this macro copy the contecnts correctly but it copies them bolded,
centered and no text wrap to the destination?
Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Macro Functionality


From
.EntireRow.Copy
Worksheets("SBX COST SHEET").Range("a17") _
.PasteSpecial Paste:=xlPasteValues

to
.EntireRow.Copy _
Destination:=Worksheets("SBX COST SHEET").Rows(17)


"Jerry Foley" wrote:

Thanks,
What should be changed to reflect the same formatting and values as the main
sheet?

"Joel" wrote:

You are pasting the values use PasteSpecial with the values option. This is
not copying the formating. Your code is inserting a new row 17. This new
row will have the same formating as Row 16.

"Jerry Foley" wrote:

Gien the following macro:
Option Explicit
Sub mastertest2()
Dim rSource As Range
Dim rCell As Range
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim wks As Worksheet

For Each wks In Worksheets(Array("SBX WORK SHEET"))
With wks
FirstRow = 4
LastRow = .Cells(.Rows.Count, 4).End(xlUp).Row
End With

For iRow = LastRow To FirstRow Step -1
Set rCell = wks.Cells(iRow, 4)
With rCell
If Not IsEmpty(.Value) Then
If IsNumeric(.Value) Then
Worksheets("SBX COST SHEET").Rows(17).Insert
.EntireRow.Copy
Worksheets("SBX COST SHEET").Range("a17") _
.PasteSpecial Paste:=xlPasteValues
End If
End If
End With
Next iRow
Next wks
End Sub

Why does this macro copy the contecnts correctly but it copies them bolded,
centered and no text wrap to the destination?
Thanks

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
Workbook with no code now ... will need macro functionality later Barb Reinhardt Excel Programming 4 October 24th 08 03:29 PM
Macro functionality JC746 Excel Worksheet Functions 4 November 16th 07 11:18 PM
Macro inhibits Excel Functionality (i.e., No Longer Able to Use Co shade Excel Programming 1 March 28th 07 02:14 AM
How to run Macro functionality for a protected worksheet aflriwanna Excel Programming 2 March 10th 06 10:11 PM
Help with Countrows functionality within a Macro Pank New Users to Excel 5 July 11th 05 07:05 PM


All times are GMT +1. The time now is 06:10 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"