I am working on a macro which will search one field for a value, if that field is has a certain value, it will go to another field, if that field is also blank it will insert some info there.
I am not sure how to complete this at all.![]()
I am working on a macro which will search one field for a value, if that field is has a certain value, it will go to another field, if that field is also blank it will insert some info there.
I am not sure how to complete this at all.![]()
Hello resnostyle,
Welcome to the Forum!
Your post doesn't provide much information. It would help to see how the data is laid out. When you say field (database term), are you referring to a cell on a Worksheet or something else? Do you want a VBA macro to this?
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
Hi Resnote, welcome to the forum.
Posting your code and your pertinent worksheet with some before/after examples should make this easy for us to help.
Click GO ADVANCED and use the paperclip icon to post up your workbook.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
?None of us is as good as all of us? - Ray Kroc
?Actually, I *am* a rocket scientist.? - JB (little ones count!)
Thanks Leith Ross for the welcome.
Sorry, I am a programmer and usually work with PHP and MySql, so my mind works in terms of databases.
I am referring to a field on the a worksheet. Let me try to provide a few more details then. I have a very wide and long excel document.
The fields I am working with are: DU, it holds United States for example. Because of the way our system is fields in CP, will not have United States. My plan is to create a excel marco which will copy the DU United States to the CP. However, I want to be sure nothing is in the CP field. I dont want it to overwrite information.
Which columns are in question? Which column holds the values you call "DU" and which column holds the values you want tested and inserted if needed?
I uploaded a sample that should help.
Last edited by resnostyle; 09-17-2009 at 03:14 PM. Reason: Removed file.
This macro will insert the values from column DU into CP if CP is empty, regardless of what the value is. You can adjust the formula used in the highlighted code to add more criteria, if needed.
Change to this to only insert if "United States" is in the DU column:![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
Last edited by JBeaucaire; 09-17-2009 at 03:15 PM.
Wow, you guys are fast here! Thanks.
Hopefully you saw the edit above with the alternate formula you can use for more specific criteria.
If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].
(Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated)
I made the changes above and now its not working right.
I get run-time error 1004.
Application defined or object defined error.
After clicking debug, it highlights this line:
![]()
Please Login or Register to view this content.
Let's see all the code, or at least all the code around the line you noted.
Here it is:
![]()
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks