Consulting

Results 1 to 2 of 2

Thread: Why does .address put $ in value

  1. #1

    Why does .address put $ in value

    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?
    [vba] ' 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
    [/vba]

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Check out Address in VBA Help
    [VBA]
    acc_cell = range("C7").Address(0,0)

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •