Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Row Equal to Another Row, Include Formatting 2

Status
Not open for further replies.

bdmangum

Technical User
Dec 6, 2006
171
US
Per the title, I'm trying to set the value of one row equal to another row, all the while maintain the first row's formatting. I would like to accomplsih this without using a copy/paste method, as per my understanding, the copy/paste method is slow when dealing with large amounts of data.

Here's what I'm doing to transfer the values. Org and Sel are simply counting variables.
Code:
WsF.Sheets("Main Data Storage").Rows(Sel).Value2 = ThisWorkbook.Sheets("Main Data Storage").Rows(Org).Value2

I've tried both the following methods to transfer the formatting, both returned errors.
Code:
WsF.Sheets("Main Data Storage").Rows(Sel).FormatConditions = ThisWorkbook.Sheets("Main Data Storage").Rows(Org).FormatConditions

WsF.Sheets("Main Data Storage").Rows(Sel).CellFormat = ThisWorkbook.Sheets("Main Data Storage").Rows(Org).CellFormat

Any help is appreciated!

TIA,
BD
 




Hi,
Code:
WsF.Sheets("Main Data Storage").Rows(Sel).Copy Destination:= ThisWorkbook.Sheets("Main Data Storage").Rows(Org)


Skip,

[glasses] When a group touring the Crest Toothpaste factory got caught in a large cooler, headlines read...
Tooth Company Freeze a Crowd! and
Many are Cold, but Few are Frozen![tongue]
 
I think that Skip meant this:
Code:
ThisWorkbook.Sheets("Main Data Storage").Rows(Sel).Copy Destination:=WsF.Sheets("Main Data Storage").Rows(Org)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I appreciate the responses, however the solution suggested did not solve the problem. None of the formatting is transfered. One cell in each row is a hyperlink, this is also not transfered. Is there another way to transfer formatting and cell-anchored hyperlinks?
 
paste special> Values then paste special > Formats

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Geoff,

Thanks for the response. I recognize that a paste special will transfer the formats as well as the values. However my understanding is that when dealing with a large number loops of the paste step, the macro will be slower due to repeated copying to the clipboard? I'm simply trying to find a faster method. The loop this code will be placed in has the potential to be dealing with thousands of rows, thus my desire for the fastest method.
 
I just realized I tested the code supplied by Skip and PHV incorrectly. The code they suggested works exactly as I need it. I have three different loops in my code which execute based upon different criteria. I had mistakenly placed the code in the wrong (they are almost identical, so it's easy to confuse them). Now that it is correctly placed, it tested perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top