Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing to different cells in Excel 1

Status
Not open for further replies.

501blues

IS-IT--Management
Aug 1, 2002
9
US
WARNING - I'm not a programmer, but I'm trying

Looking for some help.

I am trying to write to different cells based on if a particular range of cells are empty.

I have three sets of ranges that I'm dealing with .Range("F62:F66"), .Range("H62:H66") and .Range("J62:J66").


What I need it to do is this

Dim SPPEndArray(8), i As Integer, CurCell As Object
Dim SPPEndNameArray(8)

SPPEndArray(0) = Val(CamVal_TB.Value) 'Money Values
SPPEndArray(1) = Val(InsVal_TB.Value)
SPPEndArray(2) = Val(FurVal_TB.Value)
SPPEndArray(3) = Val(JewVal_TB.Value)
SPPEndArray(4) = Val(SilVal_TB.Value)
SPPEndArray(5) = Val(StaVal_TB.Value)
SPPEndArray(6) = Val(CoiVal_TB.Value)
SPPEndArray(7) = Val(FAVal_TB.Value)
SPPEndArray(8) = Val(GolVal_TB.Value)

SPPEndNameArray(0) = "Camera"
SPPEndNameArray(1) = "Music Instr"
SPPEndNameArray(2) = "Furs"
SPPEndNameArray(3) = "Jewerly"
SPPEndNameArray(4) = "Silverware"
SPPEndNameArray(5) = "Stamps"
SPPEndNameArray(6) = "Coins"
SPPEndNameArray(7) = "Fine Arts"
SPPEndNameArray(8) = "Golf"

' Checks to see if the array has a value.
' If it does then it checks the range between
' J62:J66 to write to. If blank then it write to
' the blank cell. What I need it to also do is
' write to the corresponding cell in H62:H66 with
' the array SPPEndNameArray. Evently I would like to
' create a function or procedure and pass the arrays
' and ranges to them, but I will take any help I can
' get.

For i = 0 To UBound(SPPEndArray)
If SPPEndArray(i) > 0 Then
For Each CurCell In Range("J62:J66")
If CurCell.Value = "" Then
CurCell.Value = SPPEndArray(i)
Exit For
Else
End If
Next
End If
Next i
 
After the line:
Code:
CurCell.Value = SPPEndArray(i)
add the line:
Code:
CurCell.Offset(, -2).Value = SPPEndNameArray(i)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top