Hi all,
Looking for any help with the following code:
I'm trying to have the VBA select cell CX3 and down to the last row with values in this column and paste as values. I'm trying to add it into the code I have below so it does it at the end. Any ideas for a simple line of code? I'm feeling a bit brain dead at the moment. Thank you!
Looking for any help with the following code:
I'm trying to have the VBA select cell CX3 and down to the last row with values in this column and paste as values. I'm trying to add it into the code I have below so it does it at the end. Any ideas for a simple line of code? I'm feeling a bit brain dead at the moment. Thank you!
Code:
Sub SetupDetailsTab()
'1. Select Pivot, Select B4, control+shift down, count filled rows, store count
Dim NumberofRows As Long
Dim MyUnique As Object, c As Range
Application.ScreenUpdating = False
Sheets("Pivot").Select
Range("B4").Select
Range(Selection, Selection.End(xlDown)).Select
NumberofRows = Selection.Count
'2. Select Details, Select row 3, insert count + 2 down, copy formulas from row 3 down to fourth row from bottom
Sheets("Details").Select
Rows("4:4").Select
Rows("4:" & NumberofRows + 2).Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A3:DC3").Select
Selection.AutoFill Destination:=Range("A3:DC" & NumberofRows + 2), Type:=xlFillDefault
'3. Select Pivot, Select B4, copy over to F4 and down to last row, select details tab and paste starting in B2
Sheets("Pivot").Select
Range("B4").Select
Range(Selection, Cells(Selection.End(xlDown).Row, Selection.End(xlToRight).Column - 1)).Select
Selection.Copy
Sheets("Details").Select
Range("B3").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Set MyUnique = CreateObject("Scripting.Dictionary")
Sheets("Details").Select
Range("B3").Select
Range(Selection, Selection.End(xlDown)).Select
For Each c In Selection
If c.EntireRow.Hidden = False Then MyUnique(CStr(c)) = 1
Next c
With ActiveSheet
Range("B3").Select
Selection.End(xlDown).Select
Selection.Offset(2, 0).Select
End With
Selection.Value = MyUnique.Count
Set MyUnique = Nothing
Cells.Select
Cells.EntireColumn.AutoFit
End Sub