View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default probably really simple for most, but not me

We're going to to this step by step.

First, I'm going to assume that you data is in Column A.

THis section will determine the last entry in column A

lastrow = activesheet.cells(rows.count,1).end(xlup)
Dim myRange as Range, rng as Range

set myRange = cells(1,1).resize(lastrow,1)

for each rng in myRange
if lcase(rng.value) like "*directed by*"
'The value for directed by is in the column to the right of rng
'I'm not sure what you want to do, but this is how you get it
debug.print rng.row, rng.column, rng.value, rng.offset(1,0).value
eise if lcase(rng.value) like "*writers*"
'I'm guessing there is one or more writers below this
debug.print rng.row, rng.column, rng.value, rng.offset(1,0).value
end if
next r

Is this what you're looking for?

" wrote:

Thank-you very much for your help. I'll try and make this work.

I'm sorry i wasn't very clear. I'm trying to save myself from having
to enter too much info by hand for movies in my collection. I'm
saving info like "directed by", "writers", and "15 actors" for each
movie. I've figured out how to import the info I need from IMDb.com
with the web query. The problem is once I get the worksheet with all
of the info, the worksheets aren't uniform. Sometimes the director's
name will be in A80, and sometimes a few other cells. It is always
preceded by a cell above "Directed by". The writers are in cells
below that, but their placement is even more random as are the
actors. So when I said "step in" I meant that I have two macros, the
first getting the info imported from the web into a worksheet, the I
"step in" delete or insert rows to make sure the directors are on rows
5&6, the writers on 9&10, and the actors on rows 13-27. Once I've
done that I run the next macro that places the info I want in the main
worksheet. I'm sorry I'm so dense, I've tried figuring out VBA
through trial and error. Most of my "tutoring" come from recording
macros and trying to make sense of the result and then try to
customize it. I figured out how to get around making a new sheet each
time by creating a named sheet for the imported data.

The two macros:

Sub IMDb_Consolidated()
Sheets("Import").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://imdb.com/title/[""titlenumber"",""Enter title
number.""]/fullcredits#cast", Destination:=Range( _
"A1"))
.Name = "fullcredits#cast"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = False
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Range("A1").Select
End Sub
Sub left2right()
Sheets("MDB").Select
r = Application.WorksheetFunction.CountA(Range("A:A")) + 1
Cells(r, 1) = Worksheets("Import").Range("A2")
Cells(r, 2) = Worksheets("Import").Range("A2")
Cells(r, 10) = Worksheets("Import").Range("A5")
Cells(r, 11) = Worksheets("Import").Range("A6")
Cells(r, 13) = Worksheets("Import").Range("B13")
Cells(r, 14) = Worksheets("Import").Range("B14")
Cells(r, 15) = Worksheets("Import").Range("B15")
Cells(r, 16) = Worksheets("Import").Range("B16")
Cells(r, 17) = Worksheets("Import").Range("B17")
Cells(r, 18) = Worksheets("Import").Range("B18")
Cells(r, 19) = Worksheets("Import").Range("B19")
Cells(r, 20) = Worksheets("Import").Range("B20")
Cells(r, 21) = Worksheets("Import").Range("B21")
Cells(r, 22) = Worksheets("Import").Range("B22")
Cells(r, 23) = Worksheets("Import").Range("B23")
Cells(r, 24) = Worksheets("Import").Range("B24")
Cells(r, 25) = Worksheets("Import").Range("B25")
Cells(r, 26) = Worksheets("Import").Range("B26")
Cells(r, 27) = Worksheets("Import").Range("B27")
Cells(r, 29) = Worksheets("Import").Range("A9")
Cells(r, 30) = Worksheets("Import").Range("A10")
Application.DisplayAlerts = False
Worksheets("Import").Delete
Application.DisplayAlerts = True
End Sub