Results 1 to 7 of 7

Copying filtered data to txt file

Threaded View

  1. #1
    Registered User
    Join Date
    02-27-2015
    Location
    Lithuania
    MS-Off Ver
    2010, 2013
    Posts
    26

    Copying filtered data to txt file

    Hello,

    I have this macro that copies some data from a particular range to a text file:

    
    Sub txtreport()
    
    Dim folderDest As String
    Dim fileName As String
    Dim FSO As Object
    Dim oFile As Object
    Dim Entry As Range
    Dim newDtop As Long
    Dim newDbot As Long
    Dim NewTxtFile
    
    fileName = "name" & "_" & "name.txt"
    folderDest = "C:\Dest\"
    
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set oFile = FSO.CreateTextFile(folderDest & fileName)
    
    newDtop = [H2].End(xlDown).Offset(2, 0).Row
    newDbot = [G1048576].End(xlUp).Row
    
    For Each Entry In Range(Cells(newDtop, 3), Cells(newDbot, 3))
        oFile.Write Entry.Value & "" & vbCrLf & ""
    Next Entry
    
    NewTxtFile = Shell("C:\WINDOWS\notepad.exe C:\Dest\name_name", 1)
    
    End Sub
    But I only want it to copy the data from:

    Range(Cells(newDtop, 3), Cells(newDbot, 3))

    where text "Parot" is available in:

    Range(Cells(newDtop, 7), Cells(newDbot, 7))

    A simple filter doesn't work in this case...

    Your input would be greatly appreciated


    This how I thought of doing it:

    For Each Entry In Range(Cells(newDtop, 3), Cells(newDbot, 3))
        If Range(Cells(newDtop, 7), Cells(newDbot, 7)).Value = "Parot" Then
        oFile.Write Entry.Value & "" & vbCrLf & ""
    End If
    Next Entry
    Of course this doesn't work...
    Last edited by mellowtang; 08-10-2015 at 09:44 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro that helps copying filtered data in file A and paste to file B ?
    By achimeda in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2013, 02:14 AM
  2. Copying filtered data
    By Lvenom in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-29-2010, 03:22 PM
  3. Excel 2007 : Copying and Pasting with Filtered Data
    By lambed3 in forum Excel General
    Replies: 1
    Last Post: 10-23-2008, 05:19 PM
  4. [SOLVED] Copying Filtered Data to Another Column
    By cinco5 in forum Excel General
    Replies: 1
    Last Post: 10-22-2008, 10:16 PM
  5. Copying Filtered Data
    By coopster in forum Excel General
    Replies: 6
    Last Post: 01-23-2008, 05:30 AM
  6. Copying Filtered Data
    By kmrkmj in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 11-23-2006, 08:26 AM
  7. Copying Filtered Data
    By Shirley Munro in forum Excel General
    Replies: 1
    Last Post: 06-22-2005, 09:05 PM
  8. [SOLVED] Copying filtered data
    By cghall55 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-11-2005, 01:06 PM

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