-
Solved: duplicating formats
This is bugging me: the following code does what it says on the tin - it duplicates the current row.
Only thing is that a couple of the columns in the source row it duplicates are in currency format (with the symbol left aligned in the cell) and the duplicated column formats the currency within the symbol pushed left against the text.
Is there an easy/quick way to do it? Do I have to go through every cell?
[VBA]Private Sub BtnDuplicate_Click()
Dim RowNum As Long
Dim RngThisRow, RngDupRow As Range
RowNum = ActiveCell.Row
Range("A" & (RowNum + 1)).EntireRow.Insert
Set RngThisRow = Range("B" & RowNum & ":R" & RowNum)
Set RngDupRow = Range("B" & (RowNum + 1) & ":R" & (RowNum + 1))
RngDupRow.Value = RngThisRow.Value
End Sub
[/VBA]
-
Try this -- I had it use the first row of whatever was selected but it's easy to change.
Paul
[VBA]
Sub InsertRowCopyFormats()
If Not TypeOf Selection Is Range Then Exit Sub
With Selection.Rows(1).EntireRow
.Copy
.Insert
.EntireRow.ClearContents
End With
Application.CutCopyMode = False
End Sub
[/VBA]
-
cool - took out the .EntireRow.ClearContents and it does exactly what I wanted
(normal copy & paste only coppied the visible cells - this coppies hidden columns too )
Thank you.
~G~
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules