Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
al al is offline
external usenet poster
 
Posts: 363
Default setting cell values in another worksheet?

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!

  #2   Report Post  
Posted to microsoft.public.excel.programming
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!



Reply
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
Dynamically setting CELL COLORS based on TWO OTHER cell values Tom Excel Discussion (Misc queries) 3 February 22nd 09 07:34 PM
Setting values in a cell Stephen Excel Discussion (Misc queries) 3 July 10th 08 08:23 PM
Setting Cell Values from VBA Casteele/ShadowLord Excel Programming 1 December 20th 06 12:10 AM
Need Help Setting Cell Values Jay Excel Programming 1 September 29th 05 04:09 PM
Setting Excel Cell values using C# AmitCh Excel Programming 1 December 30th 04 06:40 AM


All times are GMT +1. The time now is 05:45 PM.

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"