Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Combining Msg Box and Data

Excel 97 - Have code to get values from a closed workbook.

Once completed I want a Message Box to appear asking if you want t
view the data. If you select Yes it should open up a hidden page. I
you slect No it should move to another page.

I have worked with Msg Boxes a little but am not sure what I am doin
wrong! Keep getting error messages. Here's the code I currently have.

Sub Importmonday()
GetValuesFromAClosedWorkbook "C:\Data", "Day 1.xls", _
"Sheet1", "AX100:BR1977"
End Sub
Sub GetValuesFromAClosedWorkbook(fPath As String, _
fName As String, sName, cellRange As String)
With ActiveSheet.Range(cellRange)
.FormulaArray = "='" & fPath & "\[" & fName & "]" _
& sName & "'!" & cellRange
.Value = .Value
End With
Answer = MsgBox("Do you want to view Rosters?", _
vbYesNo + vbQuestion, "Rosters Imported!")
If Answer = vbYes Then
Sheets("Today").Select
Exit Sub
If Answer = vbYes Then
Sheets("Timeline").Visible = True
Sheets("Timeline").Select
End Sub

While I am fairly new to VBA, I know a little and can't figure out wha
to correct!

Thanks

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Combining Msg Box and Data

Monty My Man,

Your If logic is a bit skewed. You don't seem to like End Ifs. And you test
twice for vbYes!

Replace this

If Answer = vbYes Then
Sheets("Today").Select
Exit Sub
If Answer = vbYes Then
Sheets("Timeline").Visible = True
Sheets("Timeline").Select

with this

If Answer = vbYes Then
Sheets("Today").Select
Exit Sub
Else 'it must be no
Sheets("Timeline").Visible = True
Sheets("Timeline").Select
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Full Monty " wrote in message
...
Excel 97 - Have code to get values from a closed workbook.

Once completed I want a Message Box to appear asking if you want to
view the data. If you select Yes it should open up a hidden page. If
you slect No it should move to another page.

I have worked with Msg Boxes a little but am not sure what I am doing
wrong! Keep getting error messages. Here's the code I currently have.

Sub Importmonday()
GetValuesFromAClosedWorkbook "C:\Data", "Day 1.xls", _
"Sheet1", "AX100:BR1977"
End Sub
Sub GetValuesFromAClosedWorkbook(fPath As String, _
fName As String, sName, cellRange As String)
With ActiveSheet.Range(cellRange)
FormulaArray = "='" & fPath & "\[" & fName & "]" _
& sName & "'!" & cellRange
Value = .Value
End With
Answer = MsgBox("Do you want to view Rosters?", _
vbYesNo + vbQuestion, "Rosters Imported!")
If Answer = vbYes Then
Sheets("Today").Select
Exit Sub
If Answer = vbYes Then
Sheets("Timeline").Visible = True
Sheets("Timeline").Select
End Sub

While I am fairly new to VBA, I know a little and can't figure out what
to correct!

Thanks!


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Combining Msg Box and Data

Bob, once again you're my idol!

This was my first attempt at a real IF/Then type statement in VBA! Al
of the other Msg Boxes I create just use the Exit Sub if they choose N
or Cancel.

But I know I was close. I had the "Else" in there originally just no
the End If! But when I kept getting error after error, I tinkered wit
it too much I guess!

Man do I feel low right now! I just ran the macro again before
entered the correct code and the error message I was got pretty muc
told me there was no End If!

Oh, the second test you saw was a typo. In my code it says No.

I do have one more question, but I will create another post for it
This one is more out of curiosity than need!

Thanks again my friend! I am going to owe you big time

--
Message posted from http://www.ExcelForum.com

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
Combining data nitengale Excel Worksheet Functions 1 March 25th 10 06:57 PM
Combining data Dan Excel Worksheet Functions 3 May 27th 07 03:01 PM
Combining Data [email protected] Excel Discussion (Misc queries) 1 October 20th 06 07:43 PM
combining multiple rows of data into one single row of data myersjl Excel Worksheet Functions 0 March 30th 06 10:39 PM
combining data Carmel R Excel Worksheet Functions 4 September 15th 05 01:56 PM


All times are GMT +1. The time now is 08:50 PM.

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"