Good afternoon!
I am trying to come up with a way to quickly go through a large range of cells and paste the formulas (and then values over-top) to ONLY the visible rows. I feel like I am missing some small and simple thing that is keeping me from getting this to work. Any suggestions would be appreciated! I looked at manually forcing each cell, but that takes VERY long time. The document is designed to work for as little as 10 rows of data and up to 9000. I know at some point its going to go slow, but I am hopeful I can at least be as efficient as possible! Also, I must continue to use excel 2007 currently.
I am also trying to build this in a fashion so should I need this in a different area (or areas) at a different time. I can just adjust the fmla(copy) & Rng(paste) ranges & re-use the same code.
Thanks for your help!
I am trying to come up with a way to quickly go through a large range of cells and paste the formulas (and then values over-top) to ONLY the visible rows. I feel like I am missing some small and simple thing that is keeping me from getting this to work. Any suggestions would be appreciated! I looked at manually forcing each cell, but that takes VERY long time. The document is designed to work for as little as 10 rows of data and up to 9000. I know at some point its going to go slow, but I am hopeful I can at least be as efficient as possible! Also, I must continue to use excel 2007 currently.
I am also trying to build this in a fashion so should I need this in a different area (or areas) at a different time. I can just adjust the fmla(copy) & Rng(paste) ranges & re-use the same code.
Code:
Sub CopyPasteVisibleRange()
Application.ScreenUpdating = False
Dim Rng As Range, fmla As Range, lr As Long
Set fmla = Range("L6:AC6")
lr = ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.Count).Row
Set Rng = Range("L7:AC" & lr)
fmla.copy
Rng.SpecialCells(xlCellTypeVisible).PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rng.SpecialCells(xlCellTypeVisible).copy
Rng.SpecialCells(xlCellTypeVisible).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
Thanks for your help!