Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dick - I can't thank you enough for the help!!! I meant to write sooner but
some urgent things came up over the last month. I really appreciate your input and support!! Rob "Dick Kusleika" wrote: Rob MVP's, check out http://mvp.support.microsoft.com/ http://groups-beta.google.com/group/...f23cc675329ff/ Selection In general, whenever you have SomeObject.Select Selection.DoSomething you should change it to SomeObject.DoSomething There are about a half a dozen instances where selecting is necessary. The rest of the time it's not. Here's how I would rewrite your code. I don't know all the logic behind what you're doing, so you may be able to write it more efficiently than this. However, it should give you some ideas about working with object without selecting them. Sub TextFormat() Dim wshLookup As Worksheet Dim wshStep1 As Worksheet Dim rFound As Range Dim sFirstAdd As String Set wshLookup = ThisWorkbook.Sheets("Cntrywd Lookups") Set wshStep1 = ThisWorkbook.Sheets("Cntrywd Rate Sum step 1") Set rFound = wshStep1.Cells.Find( _ what:=wshLookup.Range("A12").Value, _ LookIn:=xlFormulas, _ lookat:=xlWhole) If Not rFound Is Nothing Then sFirstAdd = rFound.Address Do rFound.Font.Bold = True Set rFound = wshStep1.Cells.FindNext(rFound) Loop Until rFound.Address = sFirstAdd Or _ rFound.Value = "Program Details" End If Set rFound = wshStep1.Cells.Find( _ what:="PayOption Adjustments", _ LookIn:=xlFormulas, _ lookat:=xlWhole) If Not rFound Is Nothing Then With rFound.Offset(1, 0).End(xlToRight) wshStep1.Range(.Item(1), .Item(1).End(xlDown)).Resize(, 3).Insert xlToRight End With End If End Sub Sub CntryFormula() Dim wshStep1 As Worksheet Dim wshColor As Worksheet Dim wshLookup As Worksheet Dim wshFormula As Worksheet Dim rFound As Range Dim rDay As Range Dim rForm As Range Dim rLook As Range With ThisWorkbook Set wshStep1 = .Sheets("Cntrywd Rate Sum step 1") Set wshColor = .Sheets("Cntrywd Rate Sum - color coded") Set wshLookup = .Sheets("Cntrywd Lookups") Set wshFormula = .Sheets("Worksheet Formulas") End With wshStep1.UsedRange.Copy wshColor.Range("A1") Set rLook = wshLookup.Range("a1") Do Set rLook = rLook.Offset(1, 0) Set rFound = wshColor.Cells.Find( _ what:=rLook.Value, _ LookIn:=xlFormulas, _ lookat:=xlWhole) If Not rFound Is Nothing Then Set rDay = wshColor.Cells.Find( _ what:="day", _ after:=rFound, _ LookIn:=xlFormulas, _ lookat:=xlPart) If Not rDay Is Nothing Then With rDay.Offset(1, 0) Set rDay = wshColor.Range(.Item(1), ..Item(1).End(xlToRight)) End With Set rForm = wshFormula.Cells.Find( _ what:="Countrywide Day Adjustment Formula", _ LookIn:=xlFormulas, _ lookat:=xlPart) rForm.Offset(0, 1).Copy rDay 'Not sure about this End If End If Loop Until rLook.Value = "NonConf ARM 6m LIB IO w/3y Prepay" End Sub -- Dick Kusleika Excel MVP Daily Dose of Excel www.dicks-blog.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel Macro Security stuck on Low | Excel Discussion (Misc queries) | |||
Sorry but i am stuck again | New Users to Excel | |||
Still stuck on macro... | Excel Discussion (Misc queries) | |||
stuck on final prat of spreadsheet "macro copying cells" | Excel Programming | |||
HELP! Macro stuck-"Invalid Object" | Excel Programming |