PDA

View Full Version : Why does .address put $ in value



nathan2314
07-15-2008, 12:58 PM
Hello,
I have another question. I have a code now that runs smoothly except for one problem. I'm trying to pull in the correct first cell for a range of data. Once I have the correct cell, I want to just autofill the next 24 columns and that will pull in the rest of the data. Here is the code that does that.
Now the problem is that acc_cell and sep_cell are calculated, they put $ signs in the address. So then when I try to autofill, it doesn't increment over to the next value. Is there a quick way to set these cell values w/o .address putting $ in them?
' This determines which 'Accessions' and 'Separation' Values to read into Personnel Availability sheet
index1 = Sheets("Personnel Availability").Cells(1, 1).Value
acc_i = 0
sep_i = 0
Do Until index1 = "Accessions"
index1 = Sheets("Personnel Availability").Cells(1, 1).Offset(acc_i, 0).Value
acc_i = acc_i + 1
Loop
sep_i = acc_i + 1

grade_adjusted = Sheets("Long Term Input Data").range("AC1").Value
If grade = "O2" Then
acc_cell = range("C7").Address
sep_cell = range("C8").Address
Else
y = 0
Do Until index1 = "***" & grade_adjusted & "***"
index1 = Sheets("Data by Grade").Cells(1, 2).Offset(y, 0).Value
y = y + 1
Loop
acc_cell = Cells(y + 3, 3).Address
sep_cell = Cells(y + 4, 3).Address
End If


Sheets("Personnel Availability").Cells(acc_i, 2).Value = "=(1+'Long Term Input Data'!$V$2)*'Data by Grade'!" & acc_cell
Sheets("Personnel Availability").Cells(sep_i, 2).Value = "=(1+'Long Term Input Data'!$V$3)*'Data by Grade'!" & sep_cell

'Sheets("Personnel Availability").Cells(acc_i, 2).Select
'Selection.AutoFill Destination:=range(Cells(acc_i, 2), Cells(acc_i, 25)), Type:=xlFillDefault
Sheets("Personnel Availability").Select
Sheets("Personnel Availability").Cells(sep_i, 2).Select
With Selection
.AutoFill Destination:=Sheets("Personnel Availability").range(Sheets("Personnel Availability").Cells(sep_i, 2), _
Sheets("Personnel Availability").Cells(sep_i, 25)), Type:=xlFillDefault
End With
End Sub

mdmackillop
07-15-2008, 01:02 PM
Check out Address in VBA Help

acc_cell = range("C7").Address(0,0)