Differences With Find Method In 2000 And 2002
Jun 15, 2007
I am using the following code which works in microsoft 2002, but not in 2000. When I run it in 2000 it says " Named argument not found." The debugger highlights the line Set C through delete.
Sub DeleteRows()
Dim c As Range
With Worksheets("Sheet1").Range("A1", Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp))
Do
Set c = . Find(What:="", After:=[A1], LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not c Is Nothing Then c.Resize(12).EntireRow.Delete
Loop While Not c Is Nothing
End With
End Sub
View 7 Replies
ADVERTISEMENT
Sep 19, 2007
We're gradually moving over to Excel 2007 (from 2002) at my workplace.
My problem is that I need to run macros on both versions but I'm having trouble with the SaveAs method.
I have Excel 2007 set to save automatically in Excel 97-2003 File Format but this doesn't seem to apply to files saved using VBA.
My original 2002 code is as follows:
Workbooks.Add
ActiveWorkbook.SaveAs Filename:="C:ReportsNewFile.xls"
and 2007
Workbooks.Add
ActiveWorkbook.SaveAs Filename:="C:ReportsNewFile.xls", FileFormat:=xlExcel8
How can I get it to switch depending on the version it's run on? Unfortunately Excel 2002 doesn't recognise '=xlExcel8' so I don't think I can use an If/Else statement on the version number.
View 10 Replies
View Related
Mar 20, 2007
I have a Find Method routine in a procedure that works fine in xl2000, but fails in xl2003 with error code 9, subscript out of range.
Is there a different format for the Find Method in xl2003?
'code in xl2000
Dim CourseI As Range 'Students taking BusinessI
Dim CourseII As Range 'Students taking BusinessII
Dim BothCoursesTrue As Range
Dim Student As Range
'code
'code ...
For Each Student In CourseI
Set BothCoursesTrue = CourseII.Find(Student, LookIn:=xlValue, LookAt:=xlWhole)
If Not BothCoursesTrue Is Nothing Then Student.Offset(, 3) = 3
Next Student
View 8 Replies
View Related
Jul 8, 2006
I encounter error 1004 and copy method of range class failed in this VB routine:
fltPreviousValue = Range(varPreviousCell).Value
fltCurrentValue = Range(varCurrentCell).Value
fltNextValue = Range(varNextCell).Value
Range(varCurrentCell).Activate
If fltCurrentValue = RangeMax(ActiveCell.Offset(-2, 0), ActiveCell.Offset(2, 0)) And _
Range(varPreviousCell).Value < Range(varCurrentCell).Value And _
Range(varCurrentCell).Value >= Range(varNextCell).Value Then
Range(varCurrentCell).Select
Selection.Copy (ActiveCell.Offset(0, 6))
I am using Excel 2000 and the error occured at the last command, the bolded one.
View 9 Replies
View Related
Feb 20, 2009
I am trying to send emails using a table in Xl2002 via outlook2002.
The code below is from Walkenbach's VBA Bible for Excel 2003 and I am getting "Uesr-type not defined" error with the 1st Dim statement.
Do I need a different statement such as set OutObj = blahblah or similar?? I have searche dthe net hi & lo for a solution to this problem & I do have JW's excel VBA bible.
Sub SendEmail()
'Uses early binding
'Requires a reference to the Outlook Object Library
Dim OutlookApp As Outlook.Application
Dim MItem As Outlook.MailItem
Dim cell As Range
Dim Subj As String
Dim EmailAddr As String
Dim Recipient As String
Dim Bonus As String
Dim Msg As String
View 9 Replies
View Related
Jun 2, 2009
I have a total in F16 that i need to find an average of.
The range is set from f4 - f15 (12 months) and need to find the running average per month. but as we only have done 5 months of the year so far that is the only average required (F16/5).
I need this to count at the end of june (F16/6) basically not counting any zero months (jul, aug, sept etc until the end of each)
View 5 Replies
View Related
Aug 28, 2013
I record all jobs that come into my department. Column A contains the Job reference. Column B Contains the date that the job arrived and Column C contains the date that the job was complete.
The job can be split into several sections and can arrive on different days and the sections can be completed in different days.
I am looking to create a table that will show how long the complete job took to complete, so I am looking for the earliest date and the latest date for specific job reference numbers.
An example of my data is:
Column A Column B Column C
Ref No Date In Date Out
2013-0055 01/03/2013 25/03/2013
2013-0061 01/03/2013 03/03/2013
2013-0061 02/03/2013 20/03/2013
2013-0055 07/03/2013 28/03/2013
2013-0061 08/03/2013 19/03/2013
From the above data I am looking to create a table that will show
Ref No First Date Last Date Number of Days
2013-0055 01/03/2013 28/03/2013 28
2013-0061 01/03/2013 20/03/2013 20
I am using Excel 2000.
View 4 Replies
View Related
Mar 28, 2013
I need to find the difference between 2 excel spreadsheets. They both have the same columns.
View 10 Replies
View Related
Jan 11, 2014
I've got a list of numbers and want to show the difference between the highest number and each of the other numbers. Here's an example: (The first column is the position, the second column is the number and the third column is the difference.)
1 - 20
2 - 18 - 2
3 - 15 - 5
4 - 14 - 6
5 - 11 - 9
View 4 Replies
View Related
Jul 16, 2007
I have columns of black data that I manually go through and find regions that have cells with values that are 0.06 or more different.
I then turn these regions into blue colored regions.
Is there any way you can design a macro that goes through the spreadsheet and FILL COLOR YELLOWs a cell who is 0.06 or more less then the next cell down?
This would be so much easier on my eyes, since I usually have 80 columns and 1500 rows of data.
The blue coloring I still have to do manually because my human instinct is sometimes important there.
I would be using the FILL COLOR YELLOW cells as quick markers for my regions of interest.
View 14 Replies
View Related
Oct 5, 2012
I have been given a task to compare a set of the current months employee records to last months employee records. The goal is to a) find employees who are still in our group but may have changed managers b) find employees who are no longer in our group and c) find employees that are new to our group. Once this information has been compared between the two workbooks, it needs to be exported to a new spreadsheet that needs additional columns added for formatting in order to import the new spreadsheet in a tracking tool.
For example, last months spreadsheet includes the tracking tool ID column and has a row for each employee. For an employee that is currently with the team they would need the tracking tool ID to be put in the newly generated spreadsheet. Additionally the current employee might have changed managers and that needs to be updated. A new column needs to be added to the new spreadsheet that shows that a current employee is "Active". For employees that are new to the team they won't have a tracking tool ID because they are new but would still need to be considered "Active". And for the employees that have left the group, they would also need the tracking tool ID from the old employee record but would need a column that would mark them "InActive" since they are no longer with the team. My last step is that I want to add a column called "Team" that would iterate through each employees managers and assign them to a specific team based on the manager that they have.
My general idea has been that I need to loop through all of the employee names or numbers from this months records for comparisons to the names of employees from last months records. Once a match has been found I need to copy the entire row from the current months to the new spreadsheet. That way I will get the latest info or "row" for a current employee and that would also handle finding if they have a new manager. Next I need to pull over the tracking ID from the last months records, create a new column called "Status" and make the employee "Active" and create a "Team" column showing the team.
For employees that are no longer on team, I need to copy the whole row from the latest employee records, pull over the tracking ID from the last months records, update the "Status" column and make the employee "InActive" and populate a "Team" cell showing the team. And lastly for the new employees, I need to copy over the row from this current months spreadsheet. They wont have a tracking ID (It will populated when the Excel file is imported in the tracking tool) and I need to update the Status column to "Active" and also provide their "Team". After the new spreadsheet is generated I am done. The file can be imported. And the next month I need to kick off this script again.
View 1 Replies
View Related
Sep 4, 2013
I have two lists of data as below, and I want to find a match after excluding "Ltd" or "Limited"
example
If Cell A1 is "ABC Limited", and Cell B1 is "ABC Ltd"
This should show as a "match", otherwise it should show error.
View 1 Replies
View Related
Feb 20, 2007
I'm trying to use this Find Method and combine it with a countif or loop. Something that will count a number of occurences of a unique type of character. I'm looking to find all "F" characters in Bold, Italic and Size 16. Here's my find code that I'm trying to use. I can get it to work by itself but not along with a countif or loop.
Sub count_4()
Dim r As Range
Set r = Range("A1:A6")
With Application.FindFormat.Font
.Bold = True
.Italic = True
.Size = 16
End With
r.Find(What:="F", LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, searchformat:=True, MatchCase:=True).Activate
End Sub
View 4 Replies
View Related
Jul 17, 2007
Private Sub cmdShowdata_Click()
Dim Tgt As Worksheet
Dim Source As Range
Dim wbSource As Workbook
Dim cel As Range
Dim rng As Range
Dim c As Range
Dim i As Long
Application. ScreenUpdating = False
Set Tgt = ActiveSheet
Set wbSource = Workbooks.Open("C:Documents and SettingsDesktopStaff Recoed 2")
Set Source = wbSource.Sheets(1).Columns(1)
With Tgt
.Activate
'clear old data
Range(.Cells(3, 2), .Cells(200, 5)).ClearContents
' Loop through names in column A
For Each cel In Range(.Cells(3, 1), .Cells(Rows.Count, 1).End(xlUp))
If Not cel = "" Then...................
The above vba command which is extract the data from the Other workbooks. It looks for the "Staff 001", "Staff 002"...these parameters to transfer the data to the worksheet. But, the "Staff 001" data must appear twice in each workbooks. If i use the above command, i only can extract the FIRST "Staff 001" average data. But SECOND "Staff 001" average data cannot extract. I know it may be use FindNext method to do this but i am not sure how to write it
View 5 Replies
View Related
Jul 13, 2009
Is there a way to use the find method on 1 row only?
View 2 Replies
View Related
Aug 27, 2007
I know I must be missing something basic, but why is this code assigning a value to "NamePosition", instead of a range:
RightName = Sheets("WorkingSheet").Cells(1, 1).Value
Sheets("Tracker").Activate
Set StudentTbl = Sheets("Tracker").Range("A1:" & "Z" & NumStudents)
Set NamePosition = StudentTbl.Find(What:=RightName, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
I thought the find method returned a range?
View 6 Replies
View Related
Aug 13, 2006
I am having trouble using teh find method. I'm using it to search for a string in a column, then give me the row number, which is fine when the string is found, but when it is not I get an error of "variable not set." I'm pretty certain it is returning void, but how to I capture that? Here's the
voucher_row = Worksheets("Table").Columns("D:D").Find(voucher, LookIn:=xlValues, LookAt:=xlWhole).Row
"voucher" is a string.
View 3 Replies
View Related
Nov 8, 2006
I am going through various excel sheets looking for certain text on them. not all of the sheets will have the text.
I have been using
Cells. Find(What:="FindMe", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
and it works fine, if the text is on the sheet. When the text is not on the sheet, how should I handle this.
I have tried On Error and IsError variations, but could use a little guidance
View 4 Replies
View Related
Sep 21, 2007
The objective of this macro is to sort through a database and find all entries that match up (ie 12345 and -12345) and delete these records. when i run it foundCell always returns nothing.
Sub recSheet()
Dim balance As Double
Dim balanceCell As Double
Dim BalanceVal As Variant
Dim FoundVal As Double
Dim calcmode As Long
Dim ViewMode As Long
Dim FoundCell As Object
Dim myRng As Range
Dim sh As Worksheet
With Application
calcmode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
Set sh = ActiveSheet
Set myRng = sh.Range("I:I")
With sh
.Select .................................
View 9 Replies
View Related
Dec 14, 2008
giving me a macro to find a word in a sentence by using the "FIND" method.
For example I have a sentence say "I am happy" in which I have to search whether any of 2 words say "Happy" or "Sad" is there or not. If the sentence contains any of these words, then that row has to be highlighted.
View 9 Replies
View Related
Jan 31, 2013
How to get the GetFromClipboard syntax from here working with my code (below), but am having a really frustrating time. Basically, I need to search for whatever value is copied to the clipboard (as you can see below which will be relative to a certain cell).
Here's what I have so far, and I'm trying to replace the contents of the What:="121212121" part of the Find method to look for the clipboard contents (a 9 char number) in another sheet (where a duplicate exists - the value I am searching will be a unique identifier for the incorrectly created duplicate record that needs to be deleted).
So, What:=<insert number/string on clipboard here>
VB:
Sub DeleteDupes()
ActiveCell.Offset(0, 5).Range("A1").Select
Selection.Copy
Sheets("ActvMbrs_MatchCombos").Select
Cells.Find(What:="121212121", After:=ActiveCell, LookIn:=xlFormulas, _
[Code] .....
View 2 Replies
View Related
Dec 2, 2009
I am trying to use the .Find method to match a date. In sheet2 I have a range of cells which are formatted to only show the day "dd" (I could format each cell to show (dd-mmm-yy, etc). In sheet1, I have dates which are formatted as "January 7, 2009"
I want to create a VBA find routine which allows me to match the date from Sheet2 (Ranged between cells A1:Z1) with Sheet1. Then output a MsgBox stating "Match found in cell $A$7 of Sheet1" I have tried a formula similar to:
PHP Set FoundCell = Sheets("Sheet1").Range("A1:Z1").Find _
(what:=DateValue("January 7, 2009") ,lookin:=xlFormulas)
View 5 Replies
View Related
Mar 11, 2014
My .find function is only finding the 2nd value in a cell example If i look up the term " HOSE"
5/8 hose water Will return
5/8 heater hose will not
Basically what I am making is something I am calling a "what" button. It queries my database and returns all the part numbers with the term i put in and i thought it was working fine till i was testing it, did i do something to select this? I've tried xlpart and xl whole. Neither is working.
Here is the code below
Sub COPYPARTNUMBERINFO()Dim parttofind As String
Dim partcell As Range
Dim partref As Range
ActiveSheet.Unprotect Password:="*******"
Range("t6:T10000:u6:U10000").Select
Selection.ClearContents
parttofind = InputBox("What is the number or discription")
[code].....
View 1 Replies
View Related
Apr 18, 2006
I am using the find method to search column headings, and based on the results copy the column to another worksheet. Everything works fine except if I have a mixed text and numeric string in the cell, for example DT35. In this case the macro doesn't copy this column. I have attached the spreadsheet. CTRL - A will run the macro. The macro calls a form with checkboxes, captioned using the values in the worksheet titled "Set-Up". If a value is found in the column heading the checkbox is set to true, then when the "Copy Selected Columns to Final Sheet" button is selected the columns are copied to the "FinalSheet" worksheet. I tried using xlPart instead of xlWhole, and this works but I need to search for exact strings so xlPart isn't a great work around.
View 4 Replies
View Related
May 11, 2006
Is it possible to use the Find method using a DATE RANGE? For instance, If I have two input boxes; One, a beginning date and the other an Ending Date.
Is it possible to use Find to search for all dates that are >= strBegDate and <=strEndDate?
View 9 Replies
View Related
Sep 29, 2006
I have 2 worksheets, one called Summary and the other called LNB. Column A in both worksheets contain account numbers.
I am trying to tell excell to look at the LNB worksheet and find the account number that is on the summary worksheet. If the account number is found, then tell me the row, on the Summary worksheet, that the account was found.
The function returns "Empty" even though I know the accounts do exist on both sheets and I dont know why.
Here is the code ....
View 9 Replies
View Related
Jun 20, 2007
I have a UserForm (and associated code) to locate a specific entry in Column 'A' of a spreadsheet and insert a date, initials, and hyperlink to another file.
The basic code works fine, but did not account for the user entering a Job# that was not in the system, so I added an If/Else to account for this...
The additional code took the If (Job# not found) route every time...
Following many hours of searching this site and variations of the error handling code, I still can not get it to work.
So I'm asking for your assistance to point out why the error handling (based on other successful code found here) is not working for me.
'Insert Link
Private Sub CommandButton3_Click()
If TextBox1.Value = "" Then
MsgBox "Please Insert a Job#"
Exit Sub
ElseIf TextBox2.Value = "" Then
MsgBox "Please Insert Quoters Initials"
Exit Sub
ElseIf TextBox3.Value = "" Then
MsgBox "Please Insert Quote Date"
Exit Sub
The 'Find' part of the code is working, as the correct cell is selected after running the code... but it gives the error message, instead of executing the rest of the code...
If I remove the 'On Error Resume Next', it stops on the find block, where on inspection FindR = Nothing.
So if FindR does = Nothing, how did it manage to select the cell?
View 9 Replies
View Related
Jan 28, 2008
Asking for a row value to be returned if a string is found to exist in the sheet. Works great if it finds the value but I get the following error when the string isn't found:
Run Time Error '91':
Object Variable or With block variable not set.
Concept code follows. The commented strOCNumOF line contains the value that's found on the sheet. The uncommented line contains a value not found.
Sub find_test1()
Dim intFoundOnCur As Integer
Dim strOCNumOF As String
strOCNumOF = "AP4506"
'strOCNumOF = "BP6020"
intFoundOnCur = ThisWorkbook.ActiveSheet. Cells.Find(What:=strOCNumOF, SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
End Sub
View 4 Replies
View Related
Feb 8, 2008
This is Ridicules. The find function in vba fail to find three or four letter words like "CEO", "EATS", "CFO" ect. It gives me an error "Method ' Range' of object '_Global' failed. Run-Time Error 1004". But it works fine on five letter words or more like "Buddy". As long the caption is 5 letter words and above it works.
If CheckBox1.Value = True Then
If Not Sheets(Sheet).Cells.Find(CheckBox1.Caption) Is Nothing Then Range(CheckBox1.Caption).EntireColumn.Hidden = False
View 6 Replies
View Related
Apr 2, 2008
what i need is this code to find the data only in N11:N22 i do not want the data to be search anywhere esle ...
View 9 Replies
View Related