+ Reply to Thread
Results 1 to 3 of 3

Macro stores Active Sheet range but I need it to find a new range each time it runs

  1. #1
    Registered User
    Join Date
    02-13-2013
    Location
    Bay City, MI
    MS-Off Ver
    Excel 2010
    Posts
    8

    Question Macro stores Active Sheet range but I need it to find a new range each time it runs

    Here is the code I am using (Red shows range it picks up). I need it to refresh range on each run.

    I need to create a macro that will select a range each time it is run and not store the range from the time before the code I have been trying to use is below:

    Range("A3").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.ClearContents
    Range("A3").Select
    Workbooks.Open Filename:= _
    "C:\Documents and Settings\jroesner0\My Documents\ERRLOG.CSV"
    Columns("D:D").Select
    ActiveSheet.Range("$D$1:$D$222").RemoveDuplicates Columns:=1, Header:=xlNo
    Range("D1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    ActiveWorkbook.Close savechanges:=False
    Range("A3").Select
    ActiveSheet.Paste
    Range("D3").Select
    Workbooks.Open Filename:= _
    "C:\Documents and Settings\jroesner0\My Documents\ERRLOG.CSV"
    Columns("F:F").Select
    ActiveSheet.Range("$F$1:$F$222").RemoveDuplicates Columns:=1, Header:=xlNo
    Range("F1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    ActiveWorkbook.Close savechanges:=False
    Range("D3").Select
    ActiveSheet.Paste
    Range("A1").Select

    The CSV file is a monthly file that has our errors and dates in it I need to pull the unique processes out and dates. Then copy them to an open worksheet. The issue is the range seems to be saved in the macro and even if no data I get things pasted into my open sheet or things excluded since it only copies the number in the range.

    Thank you for reviewing and suggestions :

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Macro stores Active Sheet range but I need it to find a new range each time it runs

    Try this.

    Please Login or Register  to view this content.
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    02-13-2013
    Location
    Bay City, MI
    MS-Off Ver
    Excel 2010
    Posts
    8

    Cool Re: Macro stores Active Sheet range but I need it to find a new range each time it runs

    Thank you will try that and let you know

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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