code doenst' work right, help, please!!!

K

ksnapp

ok, here is the deal

i have 3 columns of data

the first column countains descriptions of the numbers to their right.
the second and third columns countain only numbers

I wrote a sub that will help me sort/add/order them by inserting
bunch of rows with different names and blank cells to thier right.

I then tried to write a sub that inputs the numbers. At first it inpu
its data on every other column.

No i have messed with it and it just clocks, never ending.

here is the code, it should give you a good i idea of what im trying t
do.

any help is appreciated.




Sub mutha_of_all_subs()

Range("E2").Select
Dim A As Double
Dim B As Double
Dim C As Double
Dim D As Double
Dim E As Double
Dim F As Double
Dim G As Double
Dim H As Double
Dim I As Double
Dim J As Double
Dim K As Double
Dim X As Single
Dim Y As Single

Do Until X = 15
casetext = ActiveCell.Value
Select Case (casetext)

Case Is = "TOTAL ACCOUNTS"
A = A + ActiveCell.Offset(0, 1).Value
Y = 1

Case Is = "TOTAL CLOSED ACCOUNTS"
B = B + ActiveCell.Offset(0, 1).Value
Y = 1

Case Is = "ATM BALANCE INQUIRY"
C = C + ActiveCell.Offset(0, 1).Value
Y = 1

Case Is = "ATM WITHDRAWAL"
D = D + ActiveCell.Offset(0, 1).Value
E = E + ActiveCell.Offset(0, 2).Value
Y = 1

Case Is = "POS PURCHASE"
F = F + ActiveCell.Offset(0, 1).Value
G = G + ActiveCell.Offset(0, 2).Value
Y = 1

Case Is = "MASTER DEBIT CASH"
H = H + ActiveCell.Offset(0, 1).Value
I = I + ActiveCell.Offset(0, 2).Value
Y = 1

Case Is = "MASTER DEBIT PURCHASE"
J = J + ActiveCell.Offset(0, 1).Value
K = K + ActiveCell.Offset(0, 2).Value
Y = 1

Case Is = "OPEN ACCOUNTS"
ActiveCell.Offset(0, 1).Value = A - B
ActiveCell.Offset(0, 2).Value = 0
Y = 1

Case Is = "BALANCE INQUIRY"
ActiveCell.Offset(0, 1).Value = C
ActiveCell.Offset(0, 2).Value = 0
Y = 1

Case Is = "WITHDRAWAL"
ActiveCell.Offset(0, 1).Value = D
ActiveCell.Offset(0, 2).Value = E
Y = 1

Case Is = "POINT OF SALE"
ActiveCell.Offset(0, 1).Value = F
ActiveCell.Offset(0, 2).Value = G
Y = 1

Case Is = "MASTER CASH"
ActiveCell.Offset(0, 1).Value = H
ActiveCell.Offset(0, 2).Value = I
Y = 1


Case Is = "MASTER PURCHASE"
ActiveCell.Offset(0, 1).Value = J
ActiveCell.Offset(0, 2).Value = K
Y = 1

Case Is = "TOTAL TRANSACTIONS"
ActiveCell.Offset(0, 1).Value = D + F + H + J
ActiveCell.Offset(0, 2).Value = E + G + I + K
A = 0
B = 0
C = 0
D = 0
E = 0
F = 0
G = 0
H = 0
I = 0
J = 0
K = 0
Y = 1

End Select

If Y = 1 Then
ActiveCell.Offset(1, 0).Select
End If
If ActiveCell = "" Then

X = X + 1

Else
X = 0
End If
Y = 0
Loop

End Su
 
F

Frank Kabel

Hi
if I read your code right the following could happen:
- the activecell contains a value that is not in your select case
statement (you don't have a 'case else' procedure)
- Y will stay '0' -> the selection remains unchanged
- as the activecell is not = "" X will also not be increased

So you stay with the existing value in X, Y=0 and loop endlessly
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top