Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am needing to place data into different worksheets depending on choices
from the user. I am needing to activate the worksheets based on those choices. I was using the folowing code but am running into problems, and am not sure how to get it to work. 'Day is row to place info in 'Movie is the name of the movie for that time 'PCount is the Performance Count for that time Dim Day As Integer Dim PCount As Integer Dim Movie As Integer Private Sub cmdApply_Click() Range("A3").Select Day = ActiveCell.Value + 3 '9am Range("C5").Select Movie = ActiveCell.Value Range("C3").Select PCount = ActiveCell.Value Worksheets(Movie).Active Range("C" & Day).Select ActiveCell.Value = PCount the movie variable has been done as a integer with the sheet index and as a string with the sheet name both having problems. Any help is appreciated. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have changed the way I need this to operate I need to clear out the values
on the same time and day on the other sheets so I changed it to look like this, how can I get this to work? For X = 1 To ActiveWorkbook.Sheets.Count Worksheets(X).Active Range("C" & Day).Select If X = Movie Then ActiveCell.Value = PCount Else ActiveCell.Value = 0 End If Next X The Worksheets(X).Active is where the error happens, how can I accomplish this otherwise? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try this...
dim wks as worksheet for each wks in worksheets if wks.name = "Movie" then wks.Range("C" & Day) = PCount else wks.Range("C" & Day) = 0 end if next wks -- HTH... Jim Thomlinson "Brad Sumner" wrote: I have changed the way I need this to operate I need to clear out the values on the same time and day on the other sheets so I changed it to look like this, how can I get this to work? For X = 1 To ActiveWorkbook.Sheets.Count Worksheets(X).Active Range("C" & Day).Select If X = Movie Then ActiveCell.Value = PCount Else ActiveCell.Value = 0 End If Next X The Worksheets(X).Active is where the error happens, how can I accomplish this otherwise? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Instead of using active sheets and active cells how about using the actual
sheet code names. In the VB explorer you see a listing of all of the sheets, forms and modules. Double clicking on a sheet or moduel takes you to the code for that sheet or module. At this point ensure that the properties is visible (View - Properties). The first item in the list of prpoerties for a sheet is (Name). This is the code name of the sheet and it will say something like Sheet1. You can change it and then reference the sheet directly in code. As a standard I always premise my sheet code names with sht so you could have names like shtMovies and shtHome. Once this is done in the code window you can have code like this... Private Sub cmdApply_Click() Day = shtHome.Range("A3").value + 3 '9am Movie = shtHome.Range("C5").value PCount = shtHome.Range("C3").value shtMovies.Range("C" & Day).value = PCount -- HTH... Jim Thomlinson "Brad Sumner" wrote: I am needing to place data into different worksheets depending on choices from the user. I am needing to activate the worksheets based on those choices. I was using the folowing code but am running into problems, and am not sure how to get it to work. 'Day is row to place info in 'Movie is the name of the movie for that time 'PCount is the Performance Count for that time Dim Day As Integer Dim PCount As Integer Dim Movie As Integer Private Sub cmdApply_Click() Range("A3").Select Day = ActiveCell.Value + 3 '9am Range("C5").Select Movie = ActiveCell.Value Range("C3").Select PCount = ActiveCell.Value Worksheets(Movie).Active Range("C" & Day).Select ActiveCell.Value = PCount the movie variable has been done as a integer with the sheet index and as a string with the sheet name both having problems. Any help is appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Activate method of Worksheet class fails in Excel 2000 | Excel Discussion (Misc queries) | |||
Activate method of OLEObject failed | Excel Programming | |||
Reference to a variable in windows(???).Activate | Excel Programming | |||
How to activate a file when the filename is represented by a string variable | Excel Programming | |||
why error for activate method | Excel Programming |