Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Dynamically setting CELL COLORS based on TWO OTHER cell values | Excel Discussion (Misc queries) | |||
Setting values in a cell | Excel Discussion (Misc queries) | |||
Setting Cell Values from VBA | Excel Programming | |||
Need Help Setting Cell Values | Excel Programming | |||
Setting Excel Cell values using C# | Excel Programming |