Cannot assign to range object

  • Thread starter Thread starter jason
  • Start date Start date
J

jason

Hi, I'm trying to use Visual Basic to program a macro that
will alter a worksheet (Excel 2000, version 9.0.2720;
Windows 2000.)

But every time the code gets to a place (any place) where
I make use of a range object, the code stops running and a
small popup displays the message, "Visual Basic
\newline 400". Nothing else! Just "400".

I suspect that, since I'm new to VB, I'm not setting up
the objects correctly. Below is sample code (see *** for
where it is breaking down):

Private Sub addNewList(ByVal numEmpl As Integer)

Dim mySheetName As String
Dim mySheet As Worksheet
Dim myRange As Range

Dim numOfWeeks As Integer
Dim numOfShifts As Integer
Dim baseCell As Range
Dim eachCellRow As String
Dim eachCellCol As String
Dim cellFormula As String
Dim i, j As Integer
Dim initials As String
Dim cell1, cell2, cell3 As String

'Initialize variables
mySheetName = Worksheets("ROSTER").Range("E7").Value
Set mySheet = Worksheets(mySheetName)
numOfWeeks = Worksheets("Roster").Range("E10").Value
numOfShifts = numOfWeeks * 17

'Get to our starting point
mySheet.Select
Set myRange = Range("B5")
*** (here |
v )
myRange.Select

If anyone can help, I would appreciate it very much.

Jason
 
Please don't multipost.
Also asked in .programming (with different subject).

Anders Silven
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top