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: 17
Default Activate Sheet switching

I need to be able to activate sheets. I have tried sheets.sheet3.activate and
worksheets("sheet3").activate in a couple of places each in the following
code and it does not work. I need to activate alternately between Sheet2 and
Sheet3 to insert data collected in a vb userform. But if I the sheet where
the data is tobe inserted is not on top, I get an error. If I move the sheet
to the top, the macro runs fine.

Private Sub cmdEnter_Click()

Dim LastRow As Object

Set LastRow = Sheet2.Range("a65536").End(xlUp)
LastRow.Offset(-1, 0).Select
Selection.EntireRow.Insert
ActiveCell.Offset(0, 0).Value = Date
ActiveCell.Offset(0, 1).Value = "Buy"
ActiveCell.Offset(0, 2).Value = TextBox1.Text
ActiveCell.Offset(0, 3).Value = TextBox2.Text
ActiveCell.Offset(0, 4).Value = TextBox3.Text
ActiveCell.Offset(0, 5).Value = -TextBox1.Text * TextBox3.Text
ActiveCell.Offset(0, 7).Value = -TextBox1.Text * TextBox3.Text

Set LastRow = Sheet3.Range("PrfrShrs").End(xlDown)
LastRow.Offset(1, 0).Select
Selection.EntireRow.Insert
ActiveCell.Offset(0, 0).Value = Date
ActiveCell.Offset(0, 1).Value = "Buy"
ActiveCell.Offset(0, 2).Value = TextBox1.Text
ActiveCell.Offset(0, 3).Value = TextBox2.Text
ActiveCell.Offset(0, 4).Value = TextBox3.Text
ActiveCell.Offset(0, 5).Value = -TextBox1.Text * TextBox3.Text
ActiveCell.Offset(0, 7).Value = -TextBox1.Text * TextBox3.Text


Unload Me
End Sub

Imran
 
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
excel 2003 switching ifo from one sheet to another jmh Excel Discussion (Misc queries) 3 June 5th 08 12:39 AM
Activate the top of sheet AD108 Excel Worksheet Functions 2 July 30th 06 05:27 PM
Prevent code in "Sheet Activate" from running when sheet made visible from other macr Simon Lloyd[_794_] Excel Programming 10 June 21st 06 09:15 AM
sheet.activate nk Excel Programming 0 April 8th 05 05:04 PM
Return to Current Sheet in On (sheet activate) event macro Paul Moles Excel Programming 1 March 27th 05 03:16 PM


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