Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Steve
 
Posts: n/a
Default Code not working and can't see why

I have the code below attached to a command button (GoButton) on a
worksheet called "Main". For some reason, the code shuts down and wants
to debug any line with 'Range...' in it. Does anyone know why?

Private Sub GoButton_Click()
Worksheets("InfoLoader").Activate
Range("W1:W50").Select
Selection.Value = ""
Range("E7").Select
ActiveCell.Value = ComboBox2.Value
Range("E2").Select
ActiveCell.Value = ComboBox3.Value
Range("B" & Range("F2").Value + 14 & ":B" _
& Range("F4").Value + 14).Copy Destination:=Range("W1")
End Sub

Thanks in advance

Steve

  #2   Report Post  
Jerry W. Lewis
 
Posts: n/a
Default

Possibly there is some abiguity in the context of the button click. Try
the following. Also, given the With block, the
Worksheets("InfoLoader").Activate
may not be necessary.

Private Sub GoButton_Click()
Worksheets("InfoLoader").Activate
With Worksheets("InfoLoader")
..Range("W1:W50") = ""
..Range("E7") = ComboBox2.Value
..Range("E2") = ComboBox3.Value
..Range("B" & .Range("F2").Value + 14 & ":B" _
& .Range("F4").Value + 14).Copy Destination:=.Range("W1")
End With
End Sub

Jerry

Steve wrote:

I have the code below attached to a command button (GoButton) on a
worksheet called "Main". For some reason, the code shuts down and wants
to debug any line with 'Range...' in it. Does anyone know why?

Private Sub GoButton_Click()
Worksheets("InfoLoader").Activate
Range("W1:W50").Select
Selection.Value = ""
Range("E7").Select
ActiveCell.Value = ComboBox2.Value
Range("E2").Select
ActiveCell.Value = ComboBox3.Value
Range("B" & Range("F2").Value + 14 & ":B" _
& Range("F4").Value + 14).Copy Destination:=Range("W1")
End Sub

Thanks in advance

Steve



  #3   Report Post  
Steve
 
Posts: n/a
Default

That did the trick.

Thanks a lot for that.

Steve

  #4   Report Post  
Jerry W. Lewis
 
Posts: n/a
Default

You're welcome. Glad it helped.

Jerry

Steve wrote:

That did the trick.

Thanks a lot for that.

Steve


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



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