Year dependent macros......lengthy but i really need help thx

K

KrisB_bacon

Dear Helpers,


I'm making a project to manage my school's geography department'
accounts and stock. I will try to explain my problems in as much detai
as possible within my capabilities.

I have recieved help from people such as yourselves before, bu
advanced knowledge over mine has led to me making mistakes. I reall
need some help again. Please see my attached spreadsheet. Please e-mai
me at (e-mail address removed) if you have any queries/would prefe
e-mail correspondence.

Here we go:

When you open the worksheet, you are requested to select the curren
year. This allows a year to be input into H23 in the Temp worksheet
This is then looked up in the Fieldtrips worksheet and it's macros
This is the year dependency I am using at the moment. This is part o
my desire to run macros according to what year it is. Previous hel
from this website has helped me to write macros and thier buttons t
run the No_fieldtrips

Location: Fieldtrips! worksheet

When the user presses the "Edit a Summer Fieldtrip" button, a macro i
run (called Fieldtrip_form) that displays a user form (calle
Fieldtripform). This user form asks the user to select a year from th
list and either click a Yes or a No button. My problem lies in the Ye
button and in the userform run after clicking the N
button(no_fieldtrip_selection). I have recieved help before tha
resulted in trying to type VB code that would result in, when the use
presses the Yes button, a Yes would be placed in the correct cel
(D4,D5,D6,D7,D8,D9 or D10) according to the year that was selected
However, when I click on the Yes button a compile error message appear
("compile error: invalid use of property") and I cannot find th
solution to the problem. Can you help?

Meanwhile when the No button is clicked, the no_fieldtrip_selectio
userform is displayed as intended.
When the user clicks on the No button, it runs another userfor
(no_fieldtrip_selection) and they select what year DOESN'T have
fieldtrip. I thought this work fine.
However, when one of the buttons in this no_fieldtrip_selectioi
userform is clicked on, the macro doesn't work and a run time erro
appears (when 2003 is clicked, a run-time error '424' message i
displayed) or a compile error appears (when 2005 is clicked, a compil
error is displayed). You can view this yourself as I have attached m
system with this posting. I think the solution lies in my input of th
complicated code that was suggested. I think it has many mistake
within it. I have little knowledge of the m_Col function(s) in VB. I
would be very helpful if you could explain what happens/what the cod
does, so that I could use it in the future. The other function that
do not fully understand is the If cell.....offset..(e.g. If cell
Val(FieldTripYear) Then) function. The previous helper set up the N
button and used the NoFieldtrips macro. Can this macro be used on an
column needed (any year) by just using the m_Col command? Can I do i
another way? Do I have to create a similar macro for each year (jus
changing the cells where appropriate.......tedious) or is there a shor
way to do it?

If you could help solve these problems it would make my life so muc
easier and I would be eternally grateful. Thx a lot for the help.

KrisB_baco

Attachment filename: geo systemb.zip
Download attachment: http://www.excelforum.com/attachment.php?postid=44450
 
J

Jim Rech

when I click on the Yes button a compile error message appears ("compile
error: invalid use of property") and I cannot find the solution to the
problem.

The first line of code that chokes is:

Range ("C4")

The problem is that each line has to do something, get something, assign
some value, etc. This does nothing.

If I may be so bold to say... You might be trying to run before you learn
to walk. Have you considered snuggling up to a good Excel VB book for
awhile?
 
K

KrisB_bacon

Thx for that bit about Range = "C4". I changed it to C8 and the rest
respectively. However, the error message still is displayed.

The sad thing is, I'm constrained for time (and money) and there would
be little point. This is a one off project, and I am not likely to use
excel this complicated again. Can you still help???

I'd be really grateful

Thx

KrisB_bacon
 
F

Frank Kabel

Hi
I also took a shot look at your file. Just changing Range("C4") to
Range("C8") won't help. As Jim said this line has to do something. e.g.
Range("C8").select
or
Range("C8").value = 1

Also this seems not to be the only problem. There are a lot of compiler
errors. So only fixing this also won't help. You may really consider
starting with the basisc (VBA books) or have a look at the following
sites to get started
http://www.mvps.org/dmcritchie/excel/getstarted.htm
http://support.microsoft.com/support/excel/content/vba101/default.asp

Another way would be to make your sheet a little bit less complicated.
Just use formulas and data validation for example.
 
K

KrisB_bacon

Thx guys,

Frank, what if I changed it to Range("C8")=Yes, could something lik
that work.

Could you suggest how I could use formulas/data validation to make i
simpler. I want the user form to allow people to edit whatever year'
Fieldtrip. How could I make it simpler?

I'm really grateful for your help


KrisB_bacon

(admirer of people that visit this website
 
F

Frank Kabel

Hi
why are you using Userforms at all. Your users may enter the values
directly in the respective cells :)
For data validation see the following site for a very good
introduction:
http://www.contextures.com/xlDataVal01.html

Besides your change to the Range statement will probably not give you
the result you espected
 

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

Top