Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding Matching Records in a Column

Hello,
I wanted to post because I'm a beginner with VBA.
I'm writing a program now; I have an active worksheet
(pls. refer to below) and program's objective is to be
able to find in Column A all matching records that contain
cell value "Job ID", copy its corresponding data values
(248, 249, etc.) from column B to rows in a new worksheet.
It's supposed to filter all Job IDs based on the size and
cell records of Column A. Reiteratively, once the program
is done with "Job ID", it will go to the next
(Workstation) and find all occurrences of its value and do
the same thing.

Job ID 248
Workstation ANSOS 1
Source D:

Job ID 249
Workstation ANSOS 2
Source E:

My code is below and it is really cluttered, but hoping
someone from this forum can shed some light, offer some
advice/critique.

Sub GetJobID()
Dim IRange As Range
Dim ORange As Range
Dim CRange As Range
Dim xSheet2 As Sheet2
Dim FinalRow As Range

'Find the size of today's backup log
FinalRow = xSheet2.Cells(65536, 1).End(x1Up).Row
NextCol = xSheet2.Cells(1, 255).End(x1ToLeft).Column+2

'Setup Output Range with JobID
Sheet2.Cells(1, NextCol).Value = Range
("ActiveCell").Value
Sheet2.Cells(2, NextCol).Value = "Job ID"
Set CRange = Cells(1, NextCol).Resize(2, 1)

'Setup Output Range to another column.
Range("B1").Copy = Cells(1, NextCol + 2)
Set ORange = Cells(1, NextCol + 2)

'Define the input range
Set IRange = Range("A1").Resize(FinalRow, NextCol - 2)

'Do the Advanced Filter to get unique JobID
IRange.AdvancedFilter Action = xlFilterCopy,_
CriteriaRange = CRange, CopyToRange = ORange, _
Unique = True
End Sub

The program stops at FinalRow; says "Run-Time Error 91:
Object variable or With blok variable not set."

Any and all help is much appreciated! Thanks!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Matching records in two lists Jamie Excel Discussion (Misc queries) 2 March 11th 10 06:56 PM
Matching Records Freshman Excel Worksheet Functions 8 April 2nd 08 05:17 AM
Matching Records in two tables Richard Buttrey Excel Worksheet Functions 2 February 21st 08 09:30 AM
Matching records RayB Excel Discussion (Misc queries) 1 July 18th 06 05:31 PM
Matching the same amount of records in one value to another column dodat Excel Worksheet Functions 1 January 1st 06 08:51 PM


All times are GMT +1. The time now is 11:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"