Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

anyone can help ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ReD-DevIL - 20 Mar 2006 10:44 GMT
Public Function Get_dir()

Windows("PEM.xls").Activate

With Worksheets("sheet1")
.Activate
Get_dir = .Range("H1001").Value
End With

End Function

can anyone help me figure out what does this function do ? especiall
the line Get_dir = .Range("H1001").Valu

--
ReD-DevI
Jörg - 20 Mar 2006 10:54 GMT
Hi,

especially this line returns the value of cell "H1001"

if you run a line like msgbox get_dir() you´ll get a message-box which shows
you the value of cell H1001

best regards

> Public Function Get_dir()
>
[quoted text clipped - 15 lines]
> ReD-DevIL's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=32624
> View this thread: http://www.excelforum.com/showthread.php?threadid=524267
funkymonkUK - 20 Mar 2006 11:02 GMT
ReD-DevIL Wrote:
> Public Function Get_dir()
>
[quoted text clipped - 9 lines]
> can anyone help me figure out what does this function do ? especially
> the line Get_dir = .Range("H1001").Value

While from the info you have given. I would say you have a workbook
which is opened  called PEM.xls. in this workbook there is a sheet 1
which it activates and then declares what get_dir is from the value of
cell H1001.

The get_dir value is then past onto macro which would use that value

Signature

funkymonkUK

broro183 - 20 Mar 2006 11:04 GMT
Hi,
The comments I have included after each line explain the purpose of the
line.

Public Function Get_dir()
Windows("PEM.xls").Activate
'makes the above file the active window. If the file is not open macro
will
'probably quit or may ask if you want to debug the code.
With Worksheets("sheet1")
'the "with" is used to allow for multiple things to be done to the same
object
'(ie "sheet1"). In this case, make it the active sheet & use a value
from one
'of its cells.
Activate
'makes sheet1 the active sheet
Get_dir = .Range("H1001").Value
'takes the value of cell H1001 & assigns it to a variable called
"Get_Dir"
End With
End Function

The name of the function suggests that cell H1001 may contain a file
path (or directory) & the aim is to obtain this value.
If the main/only purpose of this function is to retrieve the value of
cell H1001 it could be shortened to either of  the following lines (the
first one may not work - I haven't tested it):

Public Function Get_dir()
Get_dir = Windows("PEM.xls").Worksheets("sheet1").Range("H1001").Value
'or
Get_dir =
Workbooks("PEM.xls").Worksheets("sheet1").Range("H1001").Value
end function

hth
Rob Brockett
NZ
Always learning & the best way to learn is to experience...

Signature

broro183

ReD-DevIL - 20 Mar 2006 12:16 GMT
Thanks alot, you guys are very helpful.
Actually i am given this assignment for my attachment, whereby i hav
to edit the program but i have to understand the codes befor
proceeding to make any editing and i am not quite familiar with exce
programming. I just received this codes today, but too bad i don't hav
the program with me now. I hope you guys will be there to guide m
through... :

--
ReD-DevI
funkymonkUK - 20 Mar 2006 12:21 GMT
thanks for the response. We only try our best to help people lik
yourself who have little/no knowledge of VBA code. Its through helpin
you that others as well as ourselves can develop and learn the ways th
VBA works.

If you need any help just shout!! But not to loud some people got han
overs from the weekend
davesexcel - 20 Mar 2006 12:37 GMT
ReD-DevIL Wrote:

> Can Anyone help...

It would help readers of the forum if you actually put a topic in th
Title Box instead of " Can Anyone help"

It also helps when people are searching forums for information..
ReD-DevIL - 20 Mar 2006 14:16 GMT
Hi, i think i managed to understand the sub getdir () afte
explainations from you guys. But i encounter another problem, thi
program actually needs the user to enter userid and password. However
when i enter the userid and password, it says
Run-time error '76': Path not found

If (IsNumeric(userid)) Then
dir = Get_dir()
Open dir & "passwd" For Random Access Read As #1   :)
Get #1, userid, passwd1
Close
If (passwd <> passwd1 Or passwd = Empty) Then
MsgBox ("Invalid User ID or Password")
Else
Login_ok = 1
End If
Else
MsgBox ("Pls enter your badge number only.")
frm_newuser.Hide
End If

then the line with a smile behind is highlighted with yellow.

can anyone explain to me what does this error means

--
ReD-DevI
funkymonkUK - 20 Mar 2006 15:09 GMT
what is the value of get_dir?

do you have access to that directory
ReD-DevIL - 20 Mar 2006 22:25 GMT
dir = Get_dir()
Open dir & "passwd" For Random Access Read As #1

I presume when it open dir, then Get_dir() sub is called then a fil
named passwd is open right ? (There are two hidden file in the sam
folder as the database file userid & passwd.)  So the passwd fil
contains the password? I have access to the directory but i trie
entering all the passwods. The same error occurs

--
ReD-DevI
funkymonkUK - 21 Mar 2006 09:40 GMT
by the sounds of things you learning how to hack a excel workbook.:)

yeah you right in saying that it opens a file called passwd howeve
have you open the userid and matched it with the password?

if you want i can have a look at it for you
ReD-DevIL - 22 Mar 2006 06:40 GMT
The passwd problem is solved, my supervisor unlocked it. :)
Now, i am asked to improve the program.
If you have the time to help me, :p here is the brief introduction o
the project and what my supervisor wants me to improve on.

The company keep track of their maintenance date of their equipment s
whenever the staff finish the maintenance on a particular euqipmen
they will log in to the program to enter the record.

so when the user enter the record, the program will based on the dat
then change the colour of the cell to show that maintenance is done o
that date. The file 1.doc attached will show what i am trying to say
But that has already been done, then the improvement:

1)I have to calculate their next maintenance due date and change th
colour of the cell to indicate that.

2) Because there are 2 type of maintenance for the equipment lets sa
CAL & PEM. CAL is done every 6 months while PEM is every 3 months bu
if both maintenance due date are within one month they will have to b
brought forward to be conducted on the same date.

How do i do this

+-------------------------------------------------------------------
|Filename: 1.doc                                                    
|Download: http://www.excelforum.com/attachment.php?postid=4500     
+-------------------------------------------------------------------

--
ReD-DevI
ReD-DevIL - 22 Mar 2006 09:10 GMT
Got another question...
How can i make the program create a new worksheet yearly for next yea
with dupilcating?
E.g. for 2006 the program have to create a worksheet named 2007 an
once into 2007, it create a worksheet for 2008

--
ReD-DevI
funkymonkUK - 22 Mar 2006 10:01 GMT
ReD-DevIL Wrote:
> The passwd problem is solved, my supervisor unlocked it. :)
> Now, i am asked to improve the program.
[quoted text clipped - 19 lines]
>
> How do i do this ?

Hi Could you not do it how I have by having just the date? It woul
shorten the amount of columns used and would cut down on file size
this would also eliminate the need to have one for end year?

About the condition if they are on the same month will they been don
on the same month? please explain abit mor
funkymonkUK - 22 Mar 2006 10:28 GMT
forgot to add the attachmen

+-------------------------------------------------------------------
|Filename: Example.zip                                              
|Download: http://www.excelforum.com/attachment.php?postid=4501     
+-------------------------------------------------------------------
ReD-DevIL - 22 Mar 2006 10:42 GMT
Hi, there are alot more complicated problems with my project.
Is there any way i can contact with you more conveniently?
e.g. msn messenger

--
ReD-DevI
funkymonkUK - 22 Mar 2006 10:53 GMT
sorry unfortunately i am at work and they block msn messanger. you coul
email me using my email addy on my profile
ReD-DevIL - 22 Mar 2006 10:59 GMT
oh well its the same then haha.
Maybe i can try asking my supervisor to change the format.
On the second condition let say if PEM is conducted on 15/03/06 and CAL
is due on 13/04/06 which is lesser than one month difference, they will
both be conducted on the same day which is one 14/03/06.

Signature

ReD-DevIL

funkymonkUK - 22 Mar 2006 11:20 GMT
let me have a bash at it
ReD-DevIL - 22 Mar 2006 12:27 GMT
thanks alot :

--
ReD-DevI
funkymonkUK - 22 Mar 2006 13:59 GMT
when you need this by
funkymonkUK - 22 Mar 2006 14:10 GMT
Question.

PEM is what happens to each equipment?  
So will each epuipment have a PEM and CAL?

So are you asking is PEM and CAL are on the same month or a month late
no matter what equipment it is will be moved to the earlier date
ReD-DevIL - 23 Mar 2006 01:35 GMT
Maybe two weeks later, i'll propose the new format to my superviso
later today, depends on whether he want to change the format.

Regarding the PEM and CAL i don't actually get your question, haha m
english quite poor. Maybe i try explain again. I use the example yo
gave so you can visualise better.

You have PC, Desk chair, Printer etc. All these equipment have two typ
of maintenance namely PEM and CAL. Example PC's PEM maintenance is du
on 15/3/2006 while its CAL maintenance is due on 16/4/2006, thats fin
PC's both maintenance can be done separately because the difference i
more than a month. But if Desk chair PEM maintenance is due on 22/04/0
and its CAL maintenance is due on 1/05/06 then both maintenance have t
be brought forward to 21/04/06 a day before the earliest due date. Th
PC and Desk chair maintenance date not definitely on the same date

--
ReD-DevI
ReD-DevIL - 23 Mar 2006 10:15 GMT
Hi, my supervisor rejected the new format, he prefer the master recor
to be in graph form and viewable in terms of work week. He has alread
build the code for the master record and he wants it in thi
form(attached file

+-------------------------------------------------------------------
|Filename: Master Record.doc                                        
|Download: http://www.excelforum.com/attachment.php?postid=4511     
+-------------------------------------------------------------------

--
ReD-DevI
funkymonkUK - 28 Mar 2006 21:04 GMT
hi i been playing aroudn with it. but cant seem to come up with a
solution. sorry about that. unfortunately its beyond my excel ablities

Signature

funkymonkUK

ReD-DevIL - 29 Mar 2006 04:46 GMT
It's ok. :)  Maybe you can help me bit by bit...
I have a serial number for every equipment.

E.g.

sno         date
1            21-mar-06
2            22-mar-06
3            23-mar-06

Once the user delete the number 2 records, the number 3 will move up
but the serial number remains as 3 how can i code it to adjust the
serial number when a record is removed ?

Signature

ReD-DevIL

ReD-DevIL - 22 Mar 2006 09:35 GMT
Got another question...
How can i make the program create a new worksheet yearly for next yea
WITHOUT dupilcating?
E.g. for 2006 the program have to create a worksheet named 2007 an
once into 2007, it create a worksheet for 2008

--
ReD-DevI
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.