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

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
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
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,214,789
Messages
6,121,593
Members
449,038
Latest member
Arbind kumar

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
Back
Top