View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default setting cell values in another worksheet?

i'll take a stab but i'm not real sure what you want. i added a variable, r,
because i didn't mention what it was. always preferable to dim your variables.

Sub test()
Dim r As Long
Dim sr As Long
Dim colcount As Long

Worksheets("Data").Select
r = 2
sr = 4
colcount = 7
Worksheets("Table").Range("A" & sr).Value = Cells(r, 1)
Worksheets("Table").Range("B" & sr).Value = Hour(Cells(r, 2))
Worksheets("Table").Cells((colcount + 3), sr).Value = _
Worksheets("Table").Cells((colcount + 3), sr).Value + 1

End Sub

--


Gary


"Al" wrote in message
...
I am setting values in one worksheet while reading another worksheet. How do
I reference the cell in the worksheet I am writing to? I would rather use
cell references then I can do cell calculations
(Worksheets("Table").Cells(c+3,sr))

The following all causes errors:

Worksheets("Data").Select
sr = 4
colcount = 7
Worksheets("Table").Range("A" & sr).Value = Cells(r, 1)
Worksheets("Table").Range("B" & sr).Value = Hour(Cells(r, 2))
Worksheets("Table").Range((colcount + 3) & sr).Value =
Worksheets("Table").Range((colcount + 3) & sr) + 1

Thanks for you help!