LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default dim problem when using cell() reference

I am trying to write codes that will add or subtract a number from a previous
number, depending on whether or not certain cells are blank. It's an excel
version of a checkbook: if there's nothing listed in credit, subtract the
debit and if the debit is blank, add the credit to the previous balance.
I'm having trouble with the dim part for the total. I don't know what to
set it as.
I've attached the code I have so far.
Thanks!

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim row As Integer
row = 3
Dim total As Long

Do
Set total = Sheets("Sheet1").Cells(row, F)

If Cells(row, D) = 0 Then
If Cells(row, E) = 0 Then
total.Value = 0
Else
total.Value = Cells(row - 1, F) + Cells(row, E)
End If
Else: total.Value = Cells(row - 1, F) - Cells(row, D)
End If

If row < 100 Then
row = row + 1
Else: End
End If

Loop
End Sub
 
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
Cell reference formula problem Rocketeer Excel Discussion (Misc queries) 5 March 29th 10 01:55 AM
Problem w/ cell reference WLMPilot Excel Discussion (Misc queries) 2 March 30th 08 03:54 PM
Cell reference problem Jim Olsen Excel Worksheet Functions 4 October 31st 05 05:47 AM
problem with cell reference in =sum(offset(cell reference,x,y,z,a)). Want cell ref to be variable. [email protected] Excel Worksheet Functions 2 December 11th 04 12:05 AM
Problem with =sum(offset(cell reference,w,x,y,z). I want cell reference to be variable [email protected] Excel Worksheet Functions 2 December 11th 04 12:00 AM


All times are GMT +1. The time now is 06:51 AM.

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

About Us

"It's about Microsoft Excel"