Hi,
Two questions about copying ranges:
First, the command
seems to do nothing, but transposing the range twice, as done here
does what I expected the first line to do. Any thoughts how to tighten up the code?
Second, is there a simple way to copy the NumberFormat of each cell, similar to how the second line above copies the values? For example if the NumberFormat in A2 is "0%", in B2 is "#,##0.00" and in C2 is "mmmm d, yyyy", is there a way to apply that to, say, A1:C1? Right now I'm looping through each cell in the range to get its NumberFormat, and applying it to the corresponding cell. Is that my best bet? Thanks.
Two questions about copying ranges:
First, the command
VBA Code:
Range(Cells(1, 1), Cells(1, 3)) = Range(Cells(2, 1), Cells(2, 3))
VBA Code:
Range(Cells(1, 1), Cells(1, 3)) = Application.Transpose(Application.Transpose(Range(Cells(2, 1), Cells(2, 3))))
Second, is there a simple way to copy the NumberFormat of each cell, similar to how the second line above copies the values? For example if the NumberFormat in A2 is "0%", in B2 is "#,##0.00" and in C2 is "mmmm d, yyyy", is there a way to apply that to, say, A1:C1? Right now I'm looping through each cell in the range to get its NumberFormat, and applying it to the corresponding cell. Is that my best bet? Thanks.