Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-28-2015, 10:44 PM
macropod's Avatar
macropod macropod is offline Extract data based on pattern with respect to specific column Windows 7 64bit Extract data based on pattern with respect to specific column Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default


Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim rSrc As Long, rTgt As Long, StrTmp As String
Dim xlShtTgt As Worksheet, xlShtSrc As Worksheet, xlRng As Range
On Error Resume Next
Set xlShtTgt = Workbooks("Main.xlsx").Sheets(1)
Set xlShtSrc = Workbooks("Database2.xlsx").Sheets(1)
With xlShtTgt
  Set xlRng = .Range("A1:A" & .UsedRange.Cells.SpecialCells(xlCellTypeLastCell).Row)
End With
With xlShtTgt
  For rTgt = 1 To .UsedRange.Cells.SpecialCells(xlCellTypeLastCell).Row
    StrTmp = .Cells(rTgt, 3).Value
    With xlShtSrc
      rSrc = .Range("A1:A" & .UsedRange.Cells.SpecialCells(11).Row).Find( _
      What:=StrTmp, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
      MatchCase:=True, SearchFormat:=False).Row
    End With
    .Cells(rTgt, 3).Value = xlShtSrc.Cells(rSrc, 2).Value
  Next
  With .Columns(3)
    .WrapText = False
    .AutoFit
  End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 10-29-2015, 12:24 AM
PRA007's Avatar
PRA007 PRA007 is offline Extract data based on pattern with respect to specific column Windows 7 32bit Extract data based on pattern with respect to specific column Office 2010 32bit
Competent Performer
Extract data based on pattern with respect to specific column
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default

Sorry to bother but this is my first encounter with excel macro.

I tried running the macro from main.xlsm but its not working, nor showing any error.
I think problem is with Path to database file. How do I Run if both of my files are on desktop i.e. C:\Users\rahulkumar.patel\Desktop.
From wchich document I should run macro.
I tried changing like this.
Code:
xlShtTgt = Workbooks("C:\Users\rahulkumar.patel\Desktop\Main.xlsm").Sheets(1)
Set xlShtSrc = Workbooks("C:\Users\rahulkumar.patel\Desktop\Database2.xlsx").Sheets(1)
Can I direcly run this excel macro from CMD by saving it as .vbs?
Reply With Quote
Reply

Tags
excel vba, excel vba xml import loop



Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract data based on pattern with respect to specific column Extract Data From Text file based on Pattern PRA007 Word VBA 13 11-01-2015 11:20 PM
Powerpoint show specific data based on selection Christov PowerPoint 1 05-14-2015 09:35 PM
Extract data based on pattern with respect to specific column How to Extract Data from table based on pattern. PRA007 Word Tables 4 03-17-2015 11:05 PM
Extract data based on pattern with respect to specific column Excel VBA Macro - Deleting Specific Data based on criteria MD011 Excel Programming 3 12-10-2014 02:15 AM
Mouseover cell to indicate mouse pointer location based on Specific Row/Column values bolandk Excel 1 05-15-2014 08:22 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:43 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft