Strange Exit from code (help before noon!)

bharnett

Board Regular
Joined
Aug 5, 2004
Messages
94
When my code gets to the activecell.value = dRate it just ends. Anyone know why this is happening? I need it to hit the activecell.offset(1,0).select for the loop to work!

Sub GetRates(sheetname)
Dim sCCY As String
Dim sDate As String
Dim dRate As Double
Dim iRow As Integer
Dim iColumn As Integer
Dim wksRates As Worksheet
Dim wksCustody As Worksheet
Dim iRow2 As Integer
Dim iColumn2 As Integer
Dim iFinalColumn As Integer
Dim iFinalRow As Integer
Dim rCurrentCell As Range


iRow = 3
iColumn = 7
Set wksRates = Application.Worksheets(sheetname)
Set wksCustody = Application.Worksheets("Custody Analysis")

Do Until ActiveCell.Offset(1, -1).Value = 0


sCCY = Cells(iRow, iColumn).Value
sDate = Cells(iRow, 2).Value
wksRates.Activate

iRow2 = 1
iColumn2 = 3
iFinalColumn = 0
iFinalRow = 0
Do Until Cells(iRow2, iColumn2).Value = sCCY
iColumn2 = iColumn2 + 1
Loop
iFinalColumn = iColumn2
iRow2 = 1
iColumn2 = 3
Do Until Cells(iRow2, iColumn2).Value = sDate
iRow2 = iRow2 + 1
Loop
iFinalRow = iRow2
On Error GoTo x

dRate = Cells(iFinalRow, iFinalColumn).Value

wksCustody.Activate

ActiveCell.Value = dRate - it just exits out here for some reason. Can't figure it out!
ActiveCell.Offset(1, 0).Select
x:
Loop
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,358
Office Version
  1. 365
Platform
  1. Windows
I would suggest removing this.
Code:
On Error GoTo x
It could be hiding some error.

It might also help us help you if you told us what the code is actually meant to do.

The use of ActiveCell, Activate and Cells without worksheet references makes it hard to interpret.
 
Upvote 0

jmthompson

Well-known Member
Joined
Mar 31, 2008
Messages
966
Have you tried stepping through your codes to see if it is taking the intended actions?

Go to your worksheet, Tools-Macro-Macros. Highlight your macro and select edit, resize the VBE window until you can also see your worksheet. Place your cursor at the beginning of your code and hit F8. Each time you hit F8, the next step in your macro will occur, visible on your worksheet.
 
Upvote 0

Forum statistics

Threads
1,191,123
Messages
5,984,776
Members
439,910
Latest member
Flyingjoblo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top