Pineapple_Crazy
Board Regular
- Joined
- May 2, 2017
- Messages
- 51
Hello All,
I'm trying to paste some values in a column removing any blanks that are copied with the following code shown below. I figured I could using special cells with xlCellTypeConstants to do so, but keep receiving the error "Unable to get the SpecialCells property of the Range class". I've done some research, but haven't been able to figure out a fix. Can some advise as to what I am doing incorrectly here? Thanks in advance!!
I'm trying to paste some values in a column removing any blanks that are copied with the following code shown below. I figured I could using special cells with xlCellTypeConstants to do so, but keep receiving the error "Unable to get the SpecialCells property of the Range class". I've done some research, but haven't been able to figure out a fix. Can some advise as to what I am doing incorrectly here? Thanks in advance!!
Code:
Sub FindingValues2()
Dim findrow As Long, findrow2 As Long
Dim find As Range
Dim StrFile As String
Dim StrPath As String
Dim r1 As Long, wb As Workbook
StrPath = "Y:\Finance\BI\Pete\Pete Documents\Misc\"
StrFile = Dir(StrPath & "Vendor*" & "*.xls*")
'msg box to enter vendor ID
myValue = InputBox("Please Enter the Vendor Name", "VENDOR NAME", "MACK001")
'Opens file
Set wb = Workbooks.Open(Filename:=StrPath & StrFile)
wb.Activate
'Finding values
findrow = Range("A:A").find(myValue, Range("A1")).Row
findrow2 = Range("H:H").find("Modified:", Range("H" & findrow)).Row
r1 = findrow
Do
wb.Activate
findrow = Range("A:A").find(what:=myValue, after:=Cells(findrow, 1)).Row
findrow2 = Range("H:H").find(what:="Modified:", after:=Range("H" & findrow)).Row
Range("A" & findrow + 0 & ":A" & findrow2 + 0).Offset(0, 8)[B].SpecialCells(xlCellTypeConstants).Cells.Copy[/B]
'Shifts focus back to macro workbook and pastes data in given worksheet. Puts cursor at bottom of A (5000) and searches up for last data entered.
Windows("FinalReport_Vendor.xlsm").Activate
Sheets("Data").Activate
ActiveSheet.Range("Y5000").End(xlUp).Offset(1, 0).Select
'ActiveSheet.Paste
Selection.PasteSpecial paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=True, Transpose:=False
Loop While findrow > 1 And findrow <> r1
End Sub