Home
FREE DOWNLOADS
VBA Tutorials
VBA Code Samples
VBA Code - Excel
VBA for Beginners
Save Time on PC
SaveTimeWebsite
Save Time News
Save Time Blog
SaveTime SiteMap
Customer Service
Gibberish

Subscribe To
This Site

XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Add to Newsgator
Subscribe with Bloglines

Move to Cell Excel VBA

Move to Cell Excel VBA is a code sample which demonstrates how to move to a specific cell that you determine.

The code that finds and selects the cell is near the bottom. The code before it is code used to supply sample data.

Sub MoveToCellExcelVBA()
    Dim MaxVal As Integer
    Dim theRow As Integer
    Dim theCol As Integer
    
    Range("A1").Select
    ActiveCell.FormulaR1C1 = "1"
    Range("B1").Select
    ActiveCell.FormulaR1C1 = "2"
    Range("A1:B1").Select
    Selection.AutoFill Destination:=Range("A1:H1"), Type:=xlFillDefault
    Range("A1:H1").Select
    Range("A2").Select
    ActiveCell.FormulaR1C1 = "3"
    Range("A1:A2").Select
    Selection.AutoFill Destination:=Range("A1:A20"), Type:=xlFillDefault
    Range("A1:A20").Select
    Range("B2").Select
    ActiveCell.FormulaR1C1 = "=R1C*RC1"
    Range("B2").Select
    Selection.AutoFill Destination:=Range("B2:H2"), Type:=xlFillDefault
    Range("B2:H2").Select
    Selection.AutoFill Destination:=Range("B2:H20"), Type:=xlFillDefault
    Range("B2:H20").Select
    Range("E11").Select
    ActiveCell.FormulaR1C1 = "1000"
    Range("A1").Select
    ' The code from here finds and selects the cell
    Range("A1:H20").Select
    MaxVal = -32768
    ActiveCell.SpecialCells(xlLastCell).Select
    For intRow = 1 To ActiveCell.Row
        For intCol = 1 To ActiveCell.Column
            If Cells(intRow, intCol).Value > MaxVal Then
                MaxVal = Cells(intRow, intCol).Value
                theRow = intRow
                theCol = intCol
            End If
        Next
    Next
    Cells(theRow, theCol).Select
End Sub
Google

Return fron Move to Cell Excel VBA to"VBA Code Samples"

Return to our "Home page"



footer for move to cell excel vba page