Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default newbie, vba simple prg from a book doesn't write...see vlookup with vba?

Hi there, message already posted as a reply but fallen into disuse

Thanks thanks for your help anyway...

To see what this macro is all about, please follow this link :

http://www.good2know.freesurf.fr/startengtemp.html

And the complete macro :

Sub InsertRepresentativesInitials()
Dim ClasseurRep As Workbook
Dim Numdpt As String
Dim Colonne As Variant
Dim Initiales
Set ClasseurRep = GetObject("C:\TPExcel\Representants.xls")
Range("D4").Select
While ActiveCell.Value < ""
Numdpt = Left(ActiveCell.Value, 2)
Colonne =
ClasseurRep.Sheets(1).Range("A4:F20").Find(What:=N umdpt, _
LookIn:=xlFormulas, LookAt:=xlWhole).Address
Colonne = Range(Colonne).Column
Colonne = CInt(Colonne)
Initiales =
ClasseurRep.Sheets(1).Cells(3,Colonne).Comment.Tex t
ActiveCell.Offset(0, -1).Range("A1").Select
Wend
Set ClasseurRep = Nothing
Workbooks("clients.xls").Close
End Sub

And the not working line :

Set Colonne =
ClasseurRep.Sheets(1).Range("A4:F20").Find(What:=N umdpt, _
LookIn:=xlFormulas, LookAt:=xlWhole).Address

Just a question in between, is this line equivalent to v/hlookup
function in Excel?

I have tried a few of your answers, maybe I have missed one or two,
but it still wouldn't work.

This macro is from a book about Excel and VBA 2003. I am learning the
basic of VBA programming from there.

Hope this can help you help me.

Cheers,
Pascal

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default newbie, vba simple prg from a book doesn't write...see vlookup with vba?

I didn't download your files, but created a file to use your macro.
The line you said is not working (without "Set") worked fine for me.

Just a question in between, is this line equivalent to v/hlookup
function in Excel?


No. Find is not restricted to a rectangular block of cells. Vlookup
and Hlookup are so restricted. They look for something in the first
column (row) of the restricted range and then get the value in a
prescribed column (row) in the same row (column).

Hth,
Merjet



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default newbie, vba simple prg from a book doesn't write...see vlookup with vba?

Correction. It worked fine for me when it could find what it looked
for. However, I got a run-time error 91 when it could NOT find what it
looked for.

Hth,
Merjet


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default newbie, vba simple prg from a book doesn't write...see vlookup with vba?

On Feb 6, 7:13 pm, "merjet" wrote:
Correction. It worked fine for me when it could find what it looked
for. However, I got a run-time error 91 when it could NOT find what it
looked for.

Hth,
Merjet


so what should the not working line be like:

with or without set?

tx

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default newbie, vba simple prg from a book doesn't write...see vlookup with vba?

so what should the not working line be like:
with or without set?


Without. "Set" isn't in the Sub you posted. But you added "Set" in
your comment after the Sub.

Merjet



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default newbie, vba simple prg from a book doesn't write...see vlookup with vba?

The thing is that if you try with the files I have uploaded, it
doesn't work.What needs to be done?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default newbie, vba simple prg from a book doesn't write...see vlookup with vba?

If you getting run-time error 91, then you can do this.

After: Range("D4").Select
Insert: On Error Resume Next

Merjet


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
Newbie he I have a question about a print macro I am trying to write... Kyaba[_2_] Excel Programming 5 May 3rd 06 10:45 PM
Newbie questions - probably simple Sonnich Excel Programming 4 May 1st 06 08:42 PM
I want to write a book on my computer.How can I type? can353 New Users to Excel 4 March 17th 06 03:19 PM
How do I get a Template to write a Book ? peterm New Users to Excel 0 March 17th 05 02:39 AM
IF then write new worksheet/book Don Hansford[_2_] Excel Programming 0 April 2nd 04 04:24 PM


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