LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Use Select / Case to find certain text


Hi-

I need to move data from workbook1 to workbook2 based on the content
of Column C in workbook1. Column C contains book titles. If the titl
contains the words "Unit Resource Book", then the macro should pul
data in other columns and populate workbook2.

The problem with my macro below is that it will pull data for title
that contain *only* the words "Unit Resource Book." How should I alte
my SELECT statement so that it isn't only looking for an exact match
i.e., I want it to find all titles that contain the words "Uni
Resource Book." Thank you!

Title examples:
Physical Science Unit Resource Book
Physical Science Unit Tests
Anatomy Unit Resource Book
Physioloy



Sub titles_Test2()
' Declare variables...
Dim bk1 As Workbook, bk2 As Workbook
Dim sh1 As Worksheet, sh2 As Worksheet
Dim pgStart, pgEnd, newRow, counter As Integer
Dim activityTitle, activityID, pgRng, book, pdfName, ansKey As String
Dim rng1 As Range, cell As Range
Set bk1 = Workbooks("book1.xls")
Set bk2 = Workbooks("book2.xls")
Set sh1 = bk1.Worksheets("sheet1")
Set sh2 = bk2.Worksheets("sheet1")
Set rng1 = sh1.Range(sh1.Cells(2, 3), sh1.Cells(2, 3).End(xlDown))

newRow = 18

For Each cell In rng1

sh1.Activate
ActiveSheet.Range("C2").Select

' Get book
book = cell.Offset.Value

' Get page start
pgStart = cell.Offset(0, 1).Value

' Get page end
pgEnd = cell.Offset(0, 2).Value

' Get title
activityTitle = cell.Offset(0, 3).Value

' Get pdfName...
pdfName = cell.Offset(0, 8).Value

If pgEnd = pgStart Then
pgRng = pgStart
Else
pgRng = pgStart & "-" & pgEnd
End If

Select Case book
Case Is = "Unit Resource Book"

sh2.Cells(newRow, 3).Value = "English"

sh2.Cells(newRow, 7).Value = activityTitle

sh2.Cells(newRow, 8).Value = book

sh2.Cells(newRow, 12).Value = pgRng

sh2.Cells(newRow, 13).Value = pdfName
End Select

newRow = newRow + 1
Next
sh2.Activate
ActiveSheet.Range("A1").Select
End Su

--
marle
-----------------------------------------------------------------------
marlea's Profile: http://www.excelforum.com/member.php...fo&userid=2620
View this thread: http://www.excelforum.com/showthread.php?threadid=50651

 
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
Find Text (Lower or Upper Case) [email protected] Excel Discussion (Misc queries) 4 August 11th 08 11:42 AM
Find Upper Case Text John1950 Excel Discussion (Misc queries) 2 November 25th 05 01:57 PM
Select Case with Text Marie Excel Programming 3 February 10th 05 05:31 PM
Select Case from Text Box Input mackerma[_2_] Excel Programming 1 October 19th 04 08:14 PM
Select Case from Text Box Input mackerma Excel Programming 0 October 15th 04 08:50 PM


All times are GMT +1. The time now is 09:14 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"