Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VB programming interactive macroes

I'm programming a little in Visual Basic for Excel 2002
My problem is how to do a interactive VB-macro that open
at specifikk folder, wait for the user to pick the right
file - and then continue the macro whwen this file is ben
chosed.
Can anyone tell me - or give me a sample to use?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default VB programming interactive macroes

Hi Nils,

Try:

Sub MyTest()
Dim WB As Workbook
Dim fName As Variant

fName = Application.GetOpenFilename()
If Not fName = False Then
Set WB = Workbooks.Open(fName)
Else
'User cancelled
End If
End Sub



---
Regards,
Norman



"Nils Morten" wrote in message
...
I'm programming a little in Visual Basic for Excel 2002
My problem is how to do a interactive VB-macro that open
at specifikk folder, wait for the user to pick the right
file - and then continue the macro whwen this file is ben
chosed.
Can anyone tell me - or give me a sample to use?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VB programming interactive macroes



Thanks a lot mr Normann!
It realy works! :))

I have still 2 questions, which I hope you can give me answers to (if I
may ask..).

Question 1:
How du I cose a specific folder in that macro?

Question 2:
How do I (in macroes) change the name of a specific sheet in my
woorkbokk (the name and the sheet will be variable)?




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default VB programming interactive macroes

Hi Nils,

For your first question, try:

Sub MyTest()
Dim WB As Workbook
Dim fName As Variant

ChDir "C:\Documents and Settings\NormanJones" '<<< CHANGE

fName = Application.GetOpenFilename()
If Not fName = False Then
Set WB = Workbooks.Open(fName)
Else
'User cancelled
End If
End Sub


Change the directory path to suit.

I am not sure that I understand your second question, but, perhaps,
something like:

Sheets(1).Name = "New Name"


---
Regards,
Norman



"Nils Morten Blakstad" wrote in message
...


Thanks a lot mr Normann!
It realy works! :))

I have still 2 questions, which I hope you can give me answers to (if I
may ask..).

Question 1:
How du I cose a specific folder in that macro?

Question 2:
How do I (in macroes) change the name of a specific sheet in my
woorkbokk (the name and the sheet will be variable)?




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VB programming interactive macroes



Thanks again - very much thanks!!!!!
You realy is good at this!
I tried your solution for Q1 - and succeded again :))

My problem No. 2 whas this:

How can I copy a text from a certain cell i the spreadsheet and paste
this text as name of the sheet - or e.g. a new sheet in the workbook?
The text in the cell will vary.

Is this a better description of the problem?

Regards Nils Morten
(I hope I don't bother you too much in this case!)



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default VB programming interactive macroes

Hi Nils,

Try:

Worksheets("Sheet2").Name = _
Worksheets("Sheet1").Range("A1").Value

Change the worksheet names and cell reference to suit.

---
Regards,
Norman



"Nils Morten Blakstad" wrote in message
...


Thanks again - very much thanks!!!!!
You realy is good at this!
I tried your solution for Q1 - and succeded again :))

My problem No. 2 whas this:

How can I copy a text from a certain cell i the spreadsheet and paste
this text as name of the sheet - or e.g. a new sheet in the workbook?
The text in the cell will vary.

Is this a better description of the problem?

Regards Nils Morten
(I hope I don't bother you too much in this case!)



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VB programming interactive macroes

Thanks again
I - by Your help - is getting closer to the solution.
But sadly I still dont get it right...
The macro command is sucsessfull when inserting spreadsheet no 2, but:
When inserting the 3rd,4th (and so on...)spreadsheet in the workbook,
the macro will not function (it referes to "sheet2" all the way).

Can I still hope to be uplightend of Your kindly competence once more?



Nils Morten Blakstad


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default VB programming interactive macroes

Hi Nils,

If I understand yourr latest post correctly, you want to rename each
worksheet in the workbook and the new name is in cell A1 of each sheet.

If this corresponds to your requirements, try:

Sub Tester()

Dim WS As Worksheet

For Each WS In ActiveWorkbook.Worksheets
WS.Name = WS.Range("A1").Value
Next WS

End Sub

Change A1 to the cell containing the worksheet name.


---
Regards,
Norman




"Nils Morten Blakstad" wrote in message
...
Thanks again
I - by Your help - is getting closer to the solution.
But sadly I still dont get it right...
The macro command is sucsessfull when inserting spreadsheet no 2, but:
When inserting the 3rd,4th (and so on...)spreadsheet in the workbook,
the macro will not function (it referes to "sheet2" all the way).

Can I still hope to be uplightend of Your kindly competence once more?



Nils Morten Blakstad


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



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
Interactive course pepenacho New Users to Excel 1 July 16th 07 10:23 AM
Interactive Workbook Ryan Excel Discussion (Misc queries) 0 June 29th 07 08:48 PM
Interactive Worksheet Interactive worksheet Excel Discussion (Misc queries) 5 May 17th 05 02:41 PM
iNTERACTIVE EXCEL FILE NOT INTERACTIVE ON THE WEB kathy in kansas Excel Discussion (Misc queries) 0 January 24th 05 07:47 PM
interactive vba Hervé Hanuise Excel Programming 1 October 8th 03 05:49 PM


All times are GMT +1. The time now is 04:17 PM.

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"