So I created this code for some dummy data and it worked seamlessly. Now that I've copied it to the real workbook I get an run-time error.
I've looked at prior threads that have solved this problem and it doesn't seem to work for me.
Could you help me out?
Sub updateDept() Range("A1").EntireColumn.Insert (xlLeft) ICN_Offset = Application.WorksheetFunction.Match("ICN", Range("A1:Z1"), 0) - 1 KO_Offset = Application.WorksheetFunction.Match("KO", Range("A1:Z1"), 0) - 1 Range("A2", Range("B2").End(xlDown).Offset(0, -1)).FormulaR1C1 = _ "=RC[" & ICN_Offset & "]&RC[" & KO_Offset & "]" Range("A2").Select Do With Worksheets("All").Range("a1:a" & Worksheets("All").Range("B2").End(xlDown).Row) Set c = .Find(ActiveCell.Value, LookIn:=xlValues) If Not c Is Nothing Then ActiveCell.Offset(0, 9).Value = "Rec" ActiveCell.EntireRow.Hidden = True End If ActiveCell.Offset(1, 0).Select End With Loop Until ActiveCell.Value = "" Range("A1").EntireColumn.Delete End Sub Sub prepAll() Application.ScreenUpdating = False Application.StatusBar = "Processing" Range("A1").EntireColumn.Insert (xlLeft) ICN_Offset = WorksheetFunction.Match("ICN", Range("A1:Z1"), 0) - 1 KO_Offset = WorksheetFunction.Match("KO", Range("A1:Z1"), 0) - 1 Range("A2", Range("B2").End(xlDown).Offset(0, -1)).FormulaR1C1 = _ "=RC[" & ICN_Offset & "]&RC[" & KO_Offset & "]" ActiveSheet.Name = "All" For Each CodeSheet In ActiveWorkbook.Sheets If Not CodeSheet.Name = "All" Then CodeSheet.Activate Call updateDept End If Next CodeSheet Sheets("All").Select Range("A1").EntireColumn.Delete Application.ScreenUpdating = True Application.StatusBar = False End Sub
maffmommienqztiv
I'm new to the game.
HTML/PHP/MySQL/XML/Javascript
You're getting the run-time error because it can't find the value you're searching for, either:
1. Double-check your ranges and values, to make sure you're looking for the right thing in the right place OR
2. Put some error trapping in to deal with this OR
3. Switch to using .FIND, which returns more manageable exceptions.
Well the value is definitely in the range...hmmm...
How would I change it to .FIND? I just need to look in the header row on 1 particular sheet and match it with the header row of the another sheets
Last edited by maffmommie; 08-13-2010 at 09:40 AM. Reason: more information
maffmommienqztiv
I'm new to the game.
HTML/PHP/MySQL/XML/Javascript
Is it in the range after you account for shifting the whole range one column right?
Also you might want to specify somewhere in your code which workbook and sheet you're working with, as this may resolve some ambiguity.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks