Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Writing value to worksheet cell

This sub causes a #Value error to reflect in the cell. It kicks out when I
am trying to write some info to a separate sheet (for verification purposes).
When Excel hits the line where it write to the DebugIt sheet, Excel stops
processing the calling cell and goes to the next one.

As a test, I placed info into the cell (where it is suppose to write the
info) and that info is placed into vTemp on that line, but I can't get it to
write strTemp into that cell (the cell is not locked). The commented out
lines is where I tried to use the .cells property of Worksheets instead of
range - does the same thing.

nRow = 221, nTempRow = 1, and nEmployed = 0

Public Sub WriteData(nRow As Integer, nTempRow As Integer, nEmployed As
Integer)
Dim vRow As Variant, strTemp As String, vTemp As Variant

With Worksheets("DebugIt")
vRow = "A" + CStr(nTempRow) ' Put col A w/nTempRow into vRow
strTemp = "A" + CStr(nRow) ' Put source as "A" with row into var to
write into DebugIt sheet cell
' .Cells(nTempRow, 1).Value = strTemp
' .Cells(nTempRow, 2).Value = 0
vTemp = .Range(vRow).Value
.Range(vRow).Value = strTemp ' Write var into DebugIt sheet
vRow = "B" + CStr(nTempRow) ' change to "B" Col
vTemp = .Range(vRow).Value
.Range(vRow).Value = nEmployed ' write into DebugIt sheet
End With

End Sub

John H W
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Writing value to worksheet cell

If you are trying to execute this sub from a user defined function
referenced in a worksheet cell calculation, it will not work. UDFs are not
permitted to change the worksheet (apart from returning a value to the
calculation). It could write the value to the debug window or an external
file.

--
John Green
Sydney
Australia


"John H W" wrote in message
...
This sub causes a #Value error to reflect in the cell. It kicks out when

I
am trying to write some info to a separate sheet (for verification

purposes).
When Excel hits the line where it write to the DebugIt sheet, Excel stops
processing the calling cell and goes to the next one.

As a test, I placed info into the cell (where it is suppose to write the
info) and that info is placed into vTemp on that line, but I can't get it

to
write strTemp into that cell (the cell is not locked). The commented out
lines is where I tried to use the .cells property of Worksheets instead of
range - does the same thing.

nRow = 221, nTempRow = 1, and nEmployed = 0

Public Sub WriteData(nRow As Integer, nTempRow As Integer, nEmployed As
Integer)
Dim vRow As Variant, strTemp As String, vTemp As Variant

With Worksheets("DebugIt")
vRow = "A" + CStr(nTempRow) ' Put col A w/nTempRow into vRow
strTemp = "A" + CStr(nRow) ' Put source as "A" with row into var

to
write into DebugIt sheet cell
' .Cells(nTempRow, 1).Value = strTemp
' .Cells(nTempRow, 2).Value = 0
vTemp = .Range(vRow).Value
.Range(vRow).Value = strTemp ' Write var into DebugIt sheet
vRow = "B" + CStr(nTempRow) ' change to "B" Col
vTemp = .Range(vRow).Value
.Range(vRow).Value = nEmployed ' write into DebugIt sheet
End With

End Sub

John H W



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
Writing formula for excel worksheet Gaurav New Users to Excel 5 February 23rd 07 01:06 PM
Writing beyond the cell specified size Jean-Jerome Doucet via OfficeKB.com Excel Discussion (Misc queries) 2 June 20th 05 03:51 PM
Writing value in cell in another sheet John H W[_2_] Excel Programming 4 November 18th 04 07:10 PM
Writing to 2nd worksheet in workbook steve Excel Programming 0 August 21st 03 05:26 PM
writing to a cell Michael Miazga[_2_] Excel Programming 3 July 18th 03 01:14 AM


All times are GMT +1. The time now is 07:59 AM.

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"