excel vba - Loop finishing with error -


I need to look for each row that contains the "total" phrase, insert rows above and below , Other formats Delete the "Total" phrase from the cell, and the cell adjacent to the same line, and repeat the process for all the other rows in the report.

I have developed the macro, once it got it and all changed to "Total", I get run-time error '91': Object variable or block variable is not set is.

I would like to eliminate this error without ending the loop. It has to be executed on many sheets. Here is the code of the flesh:

  'EmployersCommissionWorldWorksonTab Macro Dim Call the range, call range, string range with the range as the first grade ("D3: D 3000") range ("D3"). Set with SetCell = Range ("D1: D3000"). (What: = "total", later: = last one, LookIn: = xlValues, LookAt: = xlPart, _SearchOrder: = xlByRows, SearchDirection: = xlNext, MatchCase: = False, SearchFormat: = False) If not found Call anything Nay if first call = get call. Find out if you will get no set cell = category ("D1: D 3000"). FindNext (After: = FoundCell) COLUMNS ("D: D"). Choose. Find (what: = "total", after: = ActiveCell, LookIn: = xlValues, _ LookAt: = xlPart, SearchOrder: = xlByRows, SearchDirection: = XLNext, MatchCase: = False, SearchFormat: = False). Activate ActiveCell. Replace: = "Total", Replacement: = "", LookAt: = xlPart, SearchOrder: = xlByRows, MatchCase: = False, _SearchFormat: = False, ReplaceFormat: = False ActiveCell.Rows ("1: 1"). EntireRow Select Acti VeCell.Activate application.CutCopyMode = False Selection.Insert Shift: = xlDown ActiveCell.Offset (3, 0) .ows ("1: 1"). Stop the whole Select the selection. Input Shift: = xlDown. . . If found, then address. Address = First ADDR loop range ("A1"), then exit. Ending sub    

There are two steps to creating an object variable. First, you declare the object variable Have to do. This error occurs because you did not set an object correctly, if it is a programming experience, then it is exactly like the reference reference exception. I ran your code and it seems that it does not do anything! There is no error at all! So I believe that there should be an error due to elsewhere in your code. Either way this line replaces any of the active worksheets with nothing:

  the cell. Replace: = "Total", Replacement: = "", LookAt: = xlPart, _ SearchOrder: = xlByRows, MatchCase: = False, SearchFormat: = False, _ ReplaceFormat: = False    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -