LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Macro getting stuck

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Macro Security stuck on Low MSullivan Excel Discussion (Misc queries) 0 September 10th 09 04:08 PM
Sorry but i am stuck again KODIAK BEAR New Users to Excel 5 October 1st 07 08:46 PM
Still stuck on macro... chip_pyp Excel Discussion (Misc queries) 2 March 28th 06 10:11 PM
stuck on final prat of spreadsheet "macro copying cells" alan_bourne[_18_] Excel Programming 4 November 17th 03 09:32 PM
HELP! Macro stuck-"Invalid Object" Ed[_9_] Excel Programming 1 July 25th 03 12:06 AM


All times are GMT +1. The time now is 11:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"