Unable to sum range variable

C

ckaramas

I am writing a simple macro. I have programmed in years, but thi
fairly straight forward.



Dim Col As Integer
Dim col2 As Integer
Dim row As Integer
Dim dom As Integer

Dim TestRange As Range

row = 111

Col = 6

dom = Application.InputBox("What Day of the Month is it?")

col2 = Col + dom

Set TestRange = Range(Cells(row, Col), Cells(row, col2))


Range("b5").Formula = "=SUM(TestRange)"
Range("B5").Select
Selection.Copy
Range("B6:B13").Select
ActiveWindow.SmallScroll Down:=6
Range("B6:B13,B17,B18,B19,B20,B21,B21").Select
Range("B21").Activate
ActiveWindow.SmallScroll Down:=15

Range("B6:B13,B17,B18,B19,B20,B21,B21,B27,B28,B29,B30,B32,B36,B37,B38").Select
Range("B38").Activate
ActiveWindow.SmallScroll Down:=9

Range("B6:B13,B17,B18,B19,B20,B21,B21,B27,B28,B29,B30,B32,B36,B37,B38,B42")
_
Select
Range("B42").Activate
ActiveWindow.SmallScroll Down:=6
Range( _

"B6:B13,B17,B18,B19,B20,B21,B21,B27,B28,B29,B30,B32,B36,B37,B38,B42,B48,B49,B50,B51,B52,B53
_
).Select
Range("B53").Activate
ActiveWindow.SmallScroll Down:=15
Range( _

"B6:B13,B17,B18,B19,B20,B21,B21,B27,B28,B29,B30,B32,B36,B37,B38,B42,B48,B49,B50,B51,B52,B53,B61:B64,B67:B69
_
).Select
Range("B67").Activate
ActiveWindow.Zoom = 85
ActiveWindow.Zoom = 70
ActiveWindow.Zoom = 55
ActiveWindow.Zoom = 70
ActiveWindow.Zoom = 85
ActiveWindow.Zoom = 100
ActiveWindow.Zoom = 115
ActiveWindow.SmallScroll Down:=63
Range( _

"B6:B13,B17,B18,B19,B20,B21,B21,B27,B28,B29,B30,B32,B36,B37,B38,B42,B48,B49,B50,B51,B52,B53,B61:B64,B67:B69,B72:B75,B78:B80,B82:B83
_
).Select
Range("B82").Activate
ActiveWindow.SmallScroll Down:=-9
ActiveSheet.Paste
ActiveWindow.SmallScroll Down:=-66
Range("B5").Select
End Sub


Why do i get a @name error when I try to sum my range variable?

I think the range is set properly, any help would be appreciated. I'
trying to add a dynamic range of cells. the end cell changes based o
the day.

chri
 

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