View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
John H W[_2_] John H W[_2_] is offline
external usenet poster
 
Posts: 6
Default Writing value in cell in another sheet

Bernie:

nTempRow is the row in sheet "Temp." I did have a typo, i.e., the line
..Range(strRow).Value=0 should have been .Range(strTemp).Value=0. When I
corrected typo, it still kicks out on the line: .Range(strRow.Value = strTemp

Thanks,
John

"Bernie Deitrick" wrote:

John,

You are assigning a value to a variable which you then write to a cell which
is then immediately over-written with a zero: Seems like you would actually
want to increment strRow, not strTemp.

strTemp = "A" + CStr(nRow)
.Range(strRow).Value = strTemp
strTemp = "B" + CStr(nTempRow)
.Range(strRow).Value = 0


HTH,
Bernie
MS Excel MVP

"John H W" wrote in message
...
I am trying to write to a cell in another sheet in the same workbook using
the following code:
strRow = "A" + CStr(nTempRow)
With Worksheets("Temp")
strTemp = "A" + CStr(nRow)
.Range(strRow).Value = strTemp
strTemp = "B" + CStr(nTempRow)
.Range(strRow).Value = 0
End With
When the code gets to fourth row, it bums out (skips to last function in
module).

The worksheet("Temp") is physically located as the first worksheet in the
workbook. I have also used its number ("Sheet10"), but the same thing
happens.
The above With is within another With (have also tried this using
Worksheet("Temp").Range(strRow).Value = ...
In the Temp worksheet, Column A is formatted as General, Row B as integer

Thanks,
John H W