Save
Random Shot: 
 

Welcome to the Sherdog Mixed Martial Arts Forums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

 

Go Back  Sherdog Mixed Martial Arts Forums > General Discussion > Mayberry Lounge > advanced MS excel macro/visual basic question

Reply
 
Sherdog Forums
LinkBack Thread Tools Search this Thread
Old 07-25-2006, 12:46 AM   #1 (permalink)
Red Belt, but BlackBeltLastYear
 
BlackBeltNow's Avatar
 
Join Date: Dec 2001
Location: daly city/San francisco
Posts: 11,358
Status: BlackBeltNow is offline
advanced MS excel macro/visual basic question

Does anyone know how to obtain a value from a cell? let's say you want to extract the value/string on cell B4. Do you know how to do that? I have a VBA book, and I can't find it (possibly b/c i don't know what the function is called so i dont' know how to look it up)

i need it for work, cuz we only have one head software engineer and he's busy working on our new robots at work.
__________________
"The president now defines progress as moving forward through time" -- Jon Stewart
BlackBeltNow is offline  | 
 
   
Reply With Quote

Old 07-25-2006, 10:37 AM   #2 (permalink)
Banned
 
childrenofbodom's Avatar
 
Join Date: May 2004
Posts: 3,755
Status: childrenofbodom is offline
umm are you trying to copy the string in b4 and paste it on another excel work sheet? what are you trying to do here?
childrenofbodom is offline  | 
 
   
Reply With Quote
Old 07-25-2006, 12:55 PM   #3 (permalink)
Red Belt, but BlackBeltLastYear
 
BlackBeltNow's Avatar
 
Join Date: Dec 2001
Location: daly city/San francisco
Posts: 11,358
Status: BlackBeltNow is offline
Lets say in B4 it says 104445. I want ot make a macro, which saves the excel file in a folder with the same value/string within a cell (i.e. B4), so if the macro works, it should save the current file as 104445.xls . A lot of coworkers are computer illiterate (they're old), and don't know how to save in the right directory

in general, my lab is disorganized. the label maker we have is just barely "sufficient". the label maker is unnencessaril difficult. it takes like 3 steps. my current (and done) method takes one. this seems to not be simple enough since the computer illiterates save the final file in the wrong directory. i want to make the save function automated. Our lab is a science lab, and it just takes too much time and energy making somethign so trivial like labels.

my current desperate solution is, when u click "save" it has a popup window and asks you to type the file name, and the macro will save using that file name u just typed into the right directory, but this is error prone cuz some ppl might type the wrong number there inadvertently, and save as the wrong file name.
__________________
"The president now defines progress as moving forward through time" -- Jon Stewart

Last edited by BlackBeltNow : 07-25-2006 at 01:02 PM.
BlackBeltNow is offline  | 
 
   
Reply With Quote
Old 07-25-2006, 04:45 PM   #4 (permalink)
Banned
 
childrenofbodom's Avatar
 
Join Date: May 2004
Posts: 3,755
Status: childrenofbodom is offline
Quote:
Sub name()
Dim fname As String
Range("b6").Activate
fname = ActiveCell

ActiveWorkbook.SaveAs fname
End Sub

alright this worked for me, tell me if you have any problems.

* for some reason when i try to run it via the module in the vba screen it returns a compile error. but when i create a button in the workbook it works..
childrenofbodom is offline  | 
 
   
Reply With Quote
Old 07-25-2006, 05:33 PM   #5 (permalink)
Red Belt, but BlackBeltLastYear
 
BlackBeltNow's Avatar
 
Join Date: Dec 2001
Location: daly city/San francisco
Posts: 11,358
Status: BlackBeltNow is offline
so waht does this function do? if called, it stores the data of B6 (err b4?) into string "fname"? so i just gotta use the value of "fname" in later code?
__________________
"The president now defines progress as moving forward through time" -- Jon Stewart
BlackBeltNow is offline  | 
 
   
Reply With Quote
Old 07-25-2006, 06:02 PM   #6 (permalink)
Banned
 
childrenofbodom's Avatar
 
Join Date: May 2004
Posts: 3,755
Status: childrenofbodom is offline
Quote:
Originally Posted by BlackBeltNow
so waht does this function do? if called, it stores the data of B6 (err b4?) into string "fname"? so i just gotta use the value of "fname" in later code?
Quote:
Sub name()
Range("b6").Activate
ActiveWorkbook.SaveAs Activecell
End Sub
god damnit i can't believe i did that... but try the one up there without the redundant code.

all that code does is when assigned to either a Ctrl + (?), or a button it Saves as the value in cell b6.
childrenofbodom is offline  | 
 
   
Reply With Quote
Old 07-25-2006, 06:08 PM   #7 (permalink)
Banned
 
childrenofbodom's Avatar
 
Join Date: May 2004
Posts: 3,755
Status: childrenofbodom is offline
oh you know what i misread what you were asking...

you want something to recognize a value in a cell while saving it in the coinciding directory?
childrenofbodom is offline  | 
 
   
Reply With Quote
Old 07-25-2006, 10:32 PM   #8 (permalink)
Red Belt, but BlackBeltLastYear
 
BlackBeltNow's Avatar
 
Join Date: Dec 2001
Location: daly city/San francisco
Posts: 11,358
Status: BlackBeltNow is offline
Quote:
Originally Posted by childrenofbodom
oh you know what i misread what you were asking...

you want something to recognize a value in a cell while saving it in the coinciding directory?
well, i just need any way of getting a cel string to be a file name. extracting the cell to a variable is good enough, cuz i know how to make a macro save a fiel w/ the value of a variable anyway, so getting a cell --> string is good enough for me.

i only write VBA by modification, not from scratch, so don't correc the following typos. i just need anyway to save the data of B4 into a variable/string. so, if u teach me how to store B4 into a string fname, i can just add the line downstream of that
Save: "C:\MyData\" "&fname" ".xls"
yes i know what ampersand may stand for another type of variable, a number or something, but dont' correct me. i only write VBA's w/ a refernece book since my major was not computer science. i'll figure it out. all i need to know is how to get a cel's info to a variable.
__________________
"The president now defines progress as moving forward through time" -- Jon Stewart
BlackBeltNow is offline  | 
 
   
Reply With Quote
Old 07-25-2006, 10:40 PM   #9 (permalink)
Banned
 
tamago's Avatar
 
Join Date: Jul 2005
Posts: 324
Status: tamago is offline
Tell you what.. I will check at work tommarrow for otther ways too. I have to use that bloated POS all day.
tamago is offline  | 
 
   
Reply With Quote
Old 07-26-2006, 12:58 PM   #10 (permalink)
Banned
 
childrenofbodom's Avatar
 
Join Date: May 2004
Posts: 3,755
Status: childrenofbodom is offline
Quote:
Originally Posted by BlackBeltNow
well, i just need any way of getting a cel string to be a file name. extracting the cell to a variable is good enough, cuz i know how to make a macro save a fiel w/ the value of a variable anyway, so getting a cell --> string is good enough for me.

i only write VBA by modification, not from scratch, so don't correc the following typos. i just need anyway to save the data of B4 into a variable/string. so, if u teach me how to store B4 into a string fname, i can just add the line downstream of that
Save: "C:\MyData\" "&fname" ".xls"
yes i know what ampersand may stand for another type of variable, a number or something, but dont' correct me. i only write VBA's w/ a refernece book since my major was not computer science. i'll figure it out. all i need to know is how to get a cel's info to a variable.
well the 2 versions i posted should work, hey why don't you post what you're working with? perhaps i can see whats going on better.
childrenofbodom is offline  | 
 
   
Reply With Quote

Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Diference Between Micro- and Macro-Evolution Colossus Mayberry Lounge 41 07-11-2006 01:03 PM
really basic Q about the basic sweep idiotboxer Grappling Technique 5 07-09-2006 05:20 AM
Basic Question about "Bang" Ludwig aes The Heavyweights: UFC and WEC 1 06-23-2006 02:43 PM
Visual Real Estate: latest alterations of the website swope Board & Site Suggestions 0 11-23-2005 02:32 AM


All times are GMT -5. The time now is 01:25 AM.


Powered by vBulletin Version {1. Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright © 2008 Sherdog.com | Privacy Policy | Click here to advertise on Sherdog