LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Global Variables

Hi,

For some reason the "Advisor" sections run fine. As soon as the ws name
changes to 'Annuity' I get a 'Method row of Object '_Global failed. wsOld
and wbkOld are set. Debug gives me the correct names. Is there something
about global variables I've missed?

Sub IDLocs(FromFileName, CopyFrom, CopyTo, DataType, FormatDateCell)

Dim Lusedrow As Long
Dim NLusedrow As Long

'Advisor
If wsOld.Name = "Advisor" And DataType = "ThisData" Then
Debug.Print "Starting Advisor ThisData " & DataType

'get the last used row
Lusedrow = wbkOld.Sheets(wsOld.Name).Cells(Rows.Count, "B"). _

End(xlUp).Row
Debug.Print "Advisor ThisData Lusedrow " & Lusedrow

Set CopyFrom = wbkOld.Sheets(wsOld.Name).Range("B2:B" & Lusedrow)
Set CopyTo = wbkNew.Sheets(wsNew.Name).Range("C4:C" & Lusedrow + 2)

Lusedrow = 0

End If

'Debug.Print "wsOld.Name & DataType ThisVolume " & wsOld.Name & " " _

& DataType
If wsOld.Name = "Advisor" And DataType = "ThisVolume" Then
Debug.Print "Starting Advisor ThisVolume " & DataType

Set CopyFrom = wbkOld.Sheets(wsOld.Name).Range("C1:D1")

'remove the lapsed month
wbkNew.Sheets(wsNew.Name).Range("K4:L4").Delete Shift:=xlUp

'add the new month data
Set CopyTo = wbkNew.Sheets(wsNew.Name).Range("K15:L15")
Set FormatDateCell = wbkNew.Sheets(wsNew.Name).Range("K15")

End If

Debug.Print "wbkOld.name " & wbkOld.Name
'Annuity
If wsOld.Name = "Annuity" And DataType = "ThisData" Then
Debug.Print "Starting Annuity ThisData " & wsOld.Name & " " & DataType

'get the last used row ***** Error is here *****
Lusedrow = wbkOld.Sheets(wsOld.Name).Cells(Rows.Count, "B"). _

End(xlUp).Row

Set CopyFrom = wbkOld.Sheets(wsOld.Name).Range("B2:B" & Lusedrow)

NLusedrow = wbkNew.Sheets(wsNew.Name).Cells(Rows.Count, "C"). _

End(xlUp).Row
NLusedrow = NLusedrow + 2 'move past last item and leave 1 space
'between
Advisor and Annuity
Set CopyTo = wbkNew.Sheets(wsNew.Name).Range("C" & NLusedrow _
& ":C" &
NLusedrow + Lusedrow)

Lusedrow = 0

End If

If wsOld.Name = "Annuity" And DataType = "ThisVolume" Then
Debug.Print "Starting Annuity & ThisVolume " & wsOld.Name & " " & _

DataType
Set CopyFrom = wbkOld.Sheets(wsOld.Name).Range("C1:D1")

'remove the lapsed month
wbkNew.Sheets(wsNew.Name).Range("H4:I4").Delete Shift:=xlUp

'add the new month data
Set CopyTo = wbkNew.Sheets(wsNew.Name).Range("H15:I15")
Set FormatDateCell = wbkNew.Sheets(wsNew.Name).Range("H15")

End If

End sub

--
Thanks for your help.
Karen53
 
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
global variables Nicolas Roth Excel Programming 3 September 25th 06 04:40 PM
Global variables Ed Excel Programming 4 August 7th 06 04:00 AM
global variables Mike Archer Excel Programming 4 May 3rd 06 07:33 PM
Global Variables mattsvai[_11_] Excel Programming 4 February 3rd 06 05:02 PM
global variables [email protected] Excel Programming 3 November 16th 05 11:44 PM


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