LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default How do I getting data from another worksheet?

I have figured out the last part of that problem, however, I have decided to
incorporate this change into all upcoming versions of my program. This has
brought up a new problem. I see that you use "Set bk = Workbooks(wbName)"
in referencing the filename so I tried to use the same idea but for some
reason it always gives me a "runtime error 9" "Subscript out of range"
error. I simply used bk2 for doing this. I figured I didn't need the error
checking since this file is obviously going to be already running.

Public Sub cmdPullDataFromOldFile_Click()
Dim wbName As String, bk As Workbook
Dim bk2 As Workbook
wbName = Application.GetOpenFilename
wbName2 = ActiveWorkbook.FullName
set bk2 = Workbooks(wbName2)
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Are you sure you want to copy all user input data from " & wbName
& " to this file?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "Confirm Data Update" ' Define title.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
Dim bClosed As Boolean
On Error Resume Next
Set bk = Workbooks(wbName)
On Error GoTo 0
If bk Is Nothing Then
bClosed = True
Set bk = Workbooks.Open(wbName)
End If
'Getting Data From Old Version
'Handicap
bk2.Worksheets("Competitors A-Z").Range("D29") =
bk.Worksheets("Competitors A-Z").Range("D29")
'Archery League Name
bk2.Worksheets("League's Score Board").Range("ArcheryLeagueName") =
bk.Worksheets("League's Score Board").Range("ArcheryLeagueName")
'Max Make-Up Scores
bk2.Worksheets("Competitors A-Z").Range("MaxMakeupScores") =
bk.Worksheets("Competitors A-Z").Range("MaxMakeupScores")
'Names
bk2.Worksheets("Competitors A-Z").Range("X4:X27").Value =
bk.Worksheets("Competitors A-Z").Range("X4:X27").Value
'Scores, X-Counts, Make-Up, and Blind Data
bk2.Worksheets("Competitors A-Z").Range("AB4:BK27").Value =
bk.Worksheets("Competitors A-Z").Range("AB4:BK27").Value
If bClosed Then bk.Close Savechanges:=False
Else ' User chose No.
MsgBox "You Have Chosen Not To Update This File With Another Files
Data"
End If
End Sub

Any help appreciated,
Dave Marden


 
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
automatically appending newly added data on worksheet to a master list worksheet tabylee via OfficeKB.com Links and Linking in Excel 0 December 17th 09 04:24 PM
Pulling data into today's worksheet from yesterday's worksheet Big UT Fan Excel Discussion (Misc queries) 4 December 12th 08 07:20 PM
Using a Worksheet Form to add data to a separate worksheet databas Rawblyn Excel Worksheet Functions 3 March 7th 06 08:17 PM
Using a column of data from 1 worksheet to extract data from another worksheet [email protected] Excel Worksheet Functions 2 February 23rd 06 04:33 PM
Attaching a JET database to an Excel Worksheet OR storing large binary data in a worksheet Ant Waters Excel Programming 1 September 3rd 03 11:34 AM


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