Results 1 to 6 of 6

Excel 2007 : VBA help

Threaded View

  1. #1
    Registered User
    Join Date
    03-31-2011
    Location
    Boston, MA
    MS-Off Ver
    Excel 2007
    Posts
    11

    VBA help

    I have some spreadsheets that need updating. I have a macro that can pull the data if I input the range manually but I was hoping to get it to pull based on a cell value as I need this to work for different values.

    Cell A15 in MySheet has the value. I want it to generate a range to use later in the macro, MyRange so that if the value of A15 was 4 I would get the range to be "A1:A4"

    Any ideas?


    Sub Test()
    '
    '
    Dim MySheet As String
    Dim MyNum As Integer
    Dim MyRange As Range
        MySheet = Range("A1").Value
        MyNum = Range("A15").Value
        MyRange = A1: AMyNum
        
        ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
        Sheets("Sheet1").Select
        Range("A1").Select
        Cells.Find(What:=MySheet, After:=ActiveCell, LookIn:= _
            xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
            xlNext, MatchCase:=False, SearchFormat:=False).Activate
            ActiveCell.Offset(0, -1).Range(MyRange).Select
        Selection.Copy
        Sheets(MySheet).Select
        Range("A17").Select
        ActiveSheet.Paste
        
        ' Notify the user that the process is complete.
       MsgBox "Fund List has been updated"
        
    End Sub
    Last edited by pike; 03-31-2011 at 04:58 PM. Reason: add code tags for newbie PM Rule

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