LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Matching Ranges

A couple of comments

1) Using the find with after will cause the search to wrap to the beginning
of the range. If you use column a and tell it to start after row 10 after
row 65536 it will continue the search a row 1.

2) xldown stops at a blank row even if the data continues after the blank
row. That is why peopleuse xlup

LastRow = Range("A" & Rows.count).end(xlup).Row

Rows.Count is a constant in excel which is the last row of the worksheet.
usually 65536 in excel 2003 but is larger in excel 2007.

"KWhamill" wrote:

Joel, Thank you
what I have thus far for the puposes of selection works pretty well. I do
things like a VBA NUB in other words I still record Macros and then clean
them up very slowly. right now it's still kind of clunky and embarrasing but
I wanted to show you this.

Application.Goto Reference:=Worksheets("Entries").Rows("1:3")
Selection.Find(what:="MCA", After:=ActiveCell, LookIn:=xlFormulas, _
lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Copy

Now this works great unless there is a space (in whole empty rows) between
the header and the first item in the list. now of course I need the data but
i need to delete the space.
the other important part here are the Formulas I needed to create this
particular piece is a number which needs to have the vector stripped from
the magnitude and reported in two different cells. actually three. it does
not appear possible to do this in a group, in other words i can't just select
the entire column containing the numbers apply the first formula and paste,
then apply the second and paste &c. It looks like i'm going to need to go
back at the end and identify each number associate it with its line and then
apply the formulas. anyway any ideas on this subject would be very
appreciated.
R,
Karl

"Joel" wrote:

This code will get you going. The find function you can change the rows to
be more than one row

from
Set c = .Rows(1).Find(what:=Header, _
LookIn:=xlValues, lookat:=xlWhole)
to
Set c = .Rows("1:3").Find(what:=Header, _
LookIn:=xlValues, lookat:=xlWhole)

I'm not sure if the formulas will be right. We may have to change the code
to a pastespecial formulas (I think this will work). I'm not sure what you
wqant done with the duplicate headers. Change the workbooknames and sheets
as necessary. the code can be modified to open the books as well.

Sub fillTemplet()

With Workbooks("Source.xls").Sheets("Sheet1")
ColCount = 1
'repeat for every column header
Do While .Cells(1, ColCount) < ""
Header = .Cells(1, ColCount)
LastRow = .Cells(Rows.Count, ColCount).End(xlUp).Row
Set CopyRange = .Range(.Cells(2, ColCount), _
.Cells(LastRow, ColCount))

With Workbooks("Templet.xls").Sheets("Sheet1")
Set c = .Rows(1).Find(what:=Header, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
MsgBox ("Could not find header : " & Header)
Else
CopyRange.Copy Destination:=c.Offset(1, 0)
End If
End With
ColCount = ColCount + 1
Loop
End With
End Sub

"KWhamill" wrote:

I want to Create a Macro that will search for a Column Header on a source
spreadsheet, match that with an Indentically named Columnheader on
spreadsheet I use as a template, then take the information in the cells below
the header in the source spreadsheet and move it to the template.
the sticky parts are as followes.
1. have to do this for about 11 Columns but some of the headers on the
template will not appear on the Source. 5 are absolutely necessary and the
other 6 are optional.
2. I need to search for the header names because they may not be in the
right order, and worse they may not be in the first row. still worse 2 of the
header names have a tendency of being duplicated in different columns with
different information, but i still them.
3. there can be anywhere from two to 100 rows of information.
4. I have some formulas I would like to Automatically populate the correct
number of cells.
I know this sounds like alot but I can't imagine that no one has ever tried
to do this or something like this before. I have the basic parts down but I'm
struggling with the things I've indicated.
Thanks

 
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
Complex matching with ranges Steven M.[_2_] Excel Worksheet Functions 1 May 22nd 09 06:12 PM
Matching two column ranges with a date Data Analyst Excel Worksheet Functions 4 November 2nd 07 06:02 PM
Range matching multiple named Ranges ben simpson Excel Discussion (Misc queries) 0 March 15th 06 06:45 PM
Comparing 2 dynamic ranges for matching names Daminc[_11_] Excel Programming 3 October 7th 05 09:07 AM
Searching and matching the textvalues in specific column ranges gki[_12_] Excel Programming 0 July 28th 04 06:43 PM


All times are GMT +1. The time now is 03:10 AM.

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

About Us

"It's about Microsoft Excel"