Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default "writing" to a range

I am trying to populate cells in columns with numeric values based on the
contents of another cell. In the following sub, the values are stored as
shown by debug.print, but they are not written to my sheet. Can anyone tell
my why, please?



Thanks in advance,



Patti







Dim myRange As Range, rCell As Range



With Worksheets("Employees")

Set myRange = .Range(.Cells(2, 3), .Cells(2, 3).End(xlDown))



For Each rCell In myRange.Cells



If rCell.Offset(0, 3).Value = "PT" Then

rCell.Offset(0, 8).Value = 200

rCell.Offset(0, 9).Value = 250

ElseIf rCell.Offset(0, 3).Value = "FT" Then

rCell.Offset(0, 8).Value = 300

rCell.Offset(0, 9).Value = 350

ElseIf rCell.Offset(0, 3).Value = "Other" Then

rCell.Offset(0, 8).Value = 400

rCell.Offset(0, 9).Value = 450

Else



End If



Debug.Print "row" & rCell & rCell.Address

Debug.Print rCell.Offset(0, 3).Value

Debug.Print rCell.Offset(0, 8).Value

Debug.Print rCell.Offset(0, 9).Value



Next



End With



End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default "writing" to a range

The code seems to work fine. If Column F does not contain PT or FT or
Other, the code doesn't write anything to the worksheet. I can't tell
from your posting what it is that your Debug commands print that is
different from your worksheet.

Alan Beban

Patti wrote:
I am trying to populate cells in columns with numeric values based on the
contents of another cell. In the following sub, the values are stored as
shown by debug.print, but they are not written to my sheet. Can anyone tell
my why, please?



Thanks in advance,



Patti







Dim myRange As Range, rCell As Range



With Worksheets("Employees")

Set myRange = .Range(.Cells(2, 3), .Cells(2, 3).End(xlDown))



For Each rCell In myRange.Cells



If rCell.Offset(0, 3).Value = "PT" Then

rCell.Offset(0, 8).Value = 200

rCell.Offset(0, 9).Value = 250

ElseIf rCell.Offset(0, 3).Value = "FT" Then

rCell.Offset(0, 8).Value = 300

rCell.Offset(0, 9).Value = 350

ElseIf rCell.Offset(0, 3).Value = "Other" Then

rCell.Offset(0, 8).Value = 400

rCell.Offset(0, 9).Value = 450

Else



End If



Debug.Print "row" & rCell & rCell.Address

Debug.Print rCell.Offset(0, 3).Value

Debug.Print rCell.Offset(0, 8).Value

Debug.Print rCell.Offset(0, 9).Value



Next



End With



End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default "writing" to a range

I got it - it was operator error : ( Thanks anyway.


"Alan Beban" wrote in message
...
The code seems to work fine. If Column F does not contain PT or FT or
Other, the code doesn't write anything to the worksheet. I can't tell
from your posting what it is that your Debug commands print that is
different from your worksheet.

Alan Beban

Patti wrote:
I am trying to populate cells in columns with numeric values based on the
contents of another cell. In the following sub, the values are stored as
shown by debug.print, but they are not written to my sheet. Can anyone
tell my why, please?



Thanks in advance,



Patti







Dim myRange As Range, rCell As Range



With Worksheets("Employees")

Set myRange = .Range(.Cells(2, 3), .Cells(2, 3).End(xlDown))



For Each rCell In myRange.Cells



If rCell.Offset(0, 3).Value = "PT" Then

rCell.Offset(0, 8).Value = 200

rCell.Offset(0, 9).Value = 250

ElseIf rCell.Offset(0, 3).Value = "FT" Then

rCell.Offset(0, 8).Value = 300

rCell.Offset(0, 9).Value = 350

ElseIf rCell.Offset(0, 3).Value = "Other" Then

rCell.Offset(0, 8).Value = 400

rCell.Offset(0, 9).Value = 450

Else



End If



Debug.Print "row" & rCell & rCell.Address

Debug.Print rCell.Offset(0, 3).Value

Debug.Print rCell.Offset(0, 8).Value

Debug.Print rCell.Offset(0, 9).Value



Next



End With



End Sub


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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
"Subscript out of range" error for: Workbooks("Test1.xls").Save Just12341234 Excel Programming 2 June 17th 05 03:16 PM
Using "Cells" to write "Range("A:A,H:H").Select" Trip Ives[_2_] Excel Programming 3 June 5th 04 03:13 PM
"Small" Multi-Dimensional Array Slow Writing To Cell Steve Hieb Excel Programming 2 September 6th 03 03:20 AM


All times are GMT +1. The time now is 09:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"