Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi Folks, I am new to the Whole VBA Programming and I am trying to insert autofilter condition in a row, when a particluar string in th worksheet is identified. All I am getting is an error in the Find method ,when I reac LookIn:= xlvalues. It give me the following compile error: Variable not defined I am not sure, how to fix this error. I tried various options, but I a not able to fix this issue. Here is the code i am working on: PHP code ------------------- Sub formatWorkbook(xlApp As Object, filename As String) 'format the workbook Dim xlWkbk As Object Dim sheet As Object Dim i As Variant Dim test As Variant Dim TopLeftCell As String Dim UsdRng As String Dim BottomRightCell As String Dim FilterRange As String Dim Findfor As String Findfor = "Cust Master ID" Set xlWkbk = xlApp.Workbooks.Open(filename) 'open the workbook For i = 1 To xlWkbk.worksheets.Count Set sheet = xlWkbk.sheets(i) TopLeftCell = sheet.Range("A:A").Find(what:=Findfor, Lookin:=xlvalues).Address UsdRng = sheet.UsedRange.Address BottomRightCell = Right(UsdRng, Len(UsdRng) - InStr(UsdRng, ":")) FilterRange = TopLeftCell & ":" & BottomRightCell sheet.Range(FilterRange).AutoFilter sheet.Range("A1").Select Next i xlWkbk.Save 'save the workbook xlWkbk.Close 'close the workbook Set xlWkbk = Nothing End Sub 'formatWorkboo ------------------- Any helps or suggestions would be appreciated. Thank You -- vincent_veg ----------------------------------------------------------------------- vincent_vega's Profile: http://www.excelforum.com/member.php...fo&userid=3639 View this thread: http://www.excelforum.com/showthread.php?threadid=56175 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VB Complie error - can You Help | Excel Programming | |||
Complie Error Help | Excel Programming | |||
complie error | Excel Programming | |||
Complie Error | Excel Programming | |||
Variable produces a complie error | Excel Programming |