Results 1 to 5 of 5

Assigning Data Range from 2 strings of text

Threaded View

  1. #1
    Registered User
    Join Date
    05-04-2009
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Assigning Data Range from 2 strings of text

    Hi,
    Im new to Macros. Im trying to find a string of text assign that to be the top of the data and then find a different string and assign that to be the bottom of the data.
    Then run a loop whilst inside that data range. Am i going about it the right way?
    Attached is a sample data file. Any help would be appreciated. I have made the parts that arent working into comments.
    Thanks, Mat

    Selection.Find(What:="Price Level", After:=ActiveCell, LookIn:=xlFormulas _
            , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate
        Dim TopRow As String
        ActiveCell.Select
        'Name the top of the data (the first "Price Level that has just been found)
    
        TopRow = ActiveCell
    
        Selection.Cut Destination:=ActiveCell.Offset(1, -1).Range("A1")
        ActiveCell.Offset(1, -1).Range("A1").Select
    
        
        ActiveCell.Columns("b:b").EntireColumn.Select
        Selection.Find(What:="Report Totals", After:=ActiveCell, LookIn:= _
            xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
            xlNext, MatchCase:=False, SearchFormat:=False).Activate
        Dim BottomRow As String
    
        ActiveCell.Select
        BottomRow = ActiveCell
        Selection.Cut Destination:=ActiveCell.Offset(1, -1).Range("A1")
        ActiveCell.Offset(1, -1).Range("A1").Select
    '    ActiveWorkbook.Names.Add Name:="DataRange", RefersTo:="TopRow: BottomRow"
    '    DataRange = Range("TopRow:BottomRow").Select
    '    Do While Range("DataRange")
        
        ActiveCell.Offset(0, 1).Columns("A:A").EntireColumn.Select
        Selection.Find(What:="Price Level", After:=ActiveCell, LookIn:=xlFormulas _
            , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate
            ActiveCell.Select
        Selection.Cut Destination:=ActiveCell.Offset(1, -1).Range("A1")
        ActiveCell.Offset(1, -1).Range("A1").Select
    
    '    Loop
    '    Wend
    Attached Files Attached Files
    Last edited by MatF; 05-05-2009 at 06:21 PM.

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