Results 1 to 8 of 8

Can't figure out how to get my offset function to work correctly in VBA

Threaded View

  1. #1
    Registered User
    Join Date
    01-14-2009
    Location
    Great Bend, Pennsylvania
    MS-Off Ver
    Excel 2000
    Posts
    22

    Can't figure out how to get my offset function to work correctly in VBA

    The code works great fills in all the values. Problem is I'm already offsetting to get my "number1" but I need to offset "DIA" at the same time to get it to stay with the "number1".

    Basically I need to select two different cells and have them offset one cell down at a time together.

    Sub calctest()
    Dim number1 As Double
    Dim number2 As Double
    Dim answer As Double
    Dim SFM As Integer
    Dim RPM As Double
    Dim MAX As Integer
    Dim ALPHA As Integer
    Dim DIA As Double
    
    SFM = InputBox("What is the SFM?")
    ALPHA = InputBox("What Alpha symbol are you using?")
    MAX = InputBox("What is maximum RPM for machine?")
    DIA = Range("b23").Value
    
    Sheets("Feeds and Diameters").Select
    
    If ALPHA = 1 Then
    ALPHA = Range("d23").Select
    ElseIf ALPHA = 2 Then
    ALPHA = Range("e23").Select
    ElseIf ALPHA = 3 Then
    ALPHA = Range("f23").Select
    ElseIf ALPHA = 4 Then
    ALPHA = Range("g23").Select
    ElseIf ALPHA = 5 Then
    ALPHA = Range("h23").Select
    ElseIf ALPHA = 6 Then
    ALPHA = Range("i23").Select
    ElseIf ALPHA = 7 Then
    ALPHA = Range("j23").Select
    ElseIf ALPHA = 8 Then
    ALPHA = Range("k23").Select
    End If
    
    Do Until Selection.Offset(0, -2).Value = ""
    
    RPM = SFM * 3.82 / DIA
    If RPM > MAX Then
    RPM = MAX
    Else
    RPM = RPM
    End If
        
    number1 = Selection.Value
    number2 = Round(RPM, 0)
    
    answer = number1 * number2
    
    Selection.Offset(0, 13).Value = Round(answer, 1)
    
    Selection.Offset(1, 0).Select
    Loop
    
    End Sub
    I am soooo close to my desired outcome, feel free to ask any questions.
    I can send over the file I'm working on if interested as well
    Last edited by Dustin S.; 04-03-2009 at 01:50 PM. Reason: Rule #1

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1