Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by Bobo--just_East_of_Madison
at 2024-07-18 08:37:10
Point:500 Replies:12 POST_ID:829017USER_ID:11919
Topic:
Microsoft Excel Spreadsheet Software;;VB Script
Hello:
I have a spreadsheet with three columns.
Column A contains client names
Column B contains client id numbers
Column C contains client addresses
Column D contains client phone numbers
1. I need to find client names in column A based on a list
2. I need to then find the client's corresponding phone number in column D
3. I then need to cut and paste into a different spreadsheet the client's name found in step one and their corresponding phone number in column D.
Searched for Macros to do this but I couldn't find one that fits my needs exactly.
VLOOKUP is helpful but doesn't provide all the steps
I have a spreadsheet with three columns.
Column A contains client names
Column B contains client id numbers
Column C contains client addresses
Column D contains client phone numbers
1. I need to find client names in column A based on a list
2. I need to then find the client's corresponding phone number in column D
3. I then need to cut and paste into a different spreadsheet the client's name found in step one and their corresponding phone number in column D.
Searched for Macros to do this but I couldn't find one that fits my needs exactly.
VLOOKUP is helpful but doesn't provide all the steps
Expert: FamousMortimer replied at 2024-07-18 11:01:19
Also, I realized that initially you wanted to read from a text file. Below is the code that will do so. Just replace the current button code with this and it will prompt for the text file to open and process it line by line the same way it does now with the range.
Dim clientTextFile As String clientTextFile = Application.GetOpenFilename Open clientTextFile For Input As #1 Do Until EOF(1) Line Input #1, txtLine FindItem (txtLine) Loop Close #1 1:2:3:4:5:6:7:8:9:10:11:12:
Expert: FamousMortimer replied at 2024-07-18 10:52:14
Wow, thank you very much. It truly means a lot to me. It's words like this, and knowing that I helped that make me realize why I got into the field I am in.
Author: Bobo--just_East_of_Madison replied at 2024-07-18 10:49:01
FamousMortimer provided to me a macro in a time of great need. And he even pointed out a deficiency in my specs that I as a Project Manger should definitely have accounted for. This was for work and the need for it was being pressed upon me by my superiors. A high-stress situation. This is a great service and this gentleman I dealt with is beyond exceptional, in acumen and in going above and beyond.
Expert: FamousMortimer replied at 2024-07-18 10:44:02
*blush*
Glad to help.
Glad to help.
Author: Bobo--just_East_of_Madison replied at 2024-07-18 10:42:59
Also, I realized that initially you wanted to read from a text file. Below is the code that will do so. Just replace the current button code with this and it will prompt for the text file to open and process it line by line the same way it does now with the range.
Dim clientTextFile As String clientTextFile = Application.GetOpenFilename Open clientTextFile For Input As #1 Do Until EOF(1) Line Input #1, txtLine FindItem (txtLine) Loop Close #1 1:2:3:4:5:6:7:8:9:10:11:12:
Accepted Solution
Expert: FamousMortimer replied at 2024-07-18 10:19:22
500 points EXCELLENT
Here you go.
I also added some comments to the code so you can see how it works and adapt it if need be.
I also added some comments to the code so you can see how it works and adapt it if need be.
Expert: FamousMortimer replied at 2024-07-18 10:08:08
Sure no problem. Give me a few.
Author: Bobo--just_East_of_Madison replied at 2024-07-18 10:06:50
@FamousMortimer
Works like a charm. Thanks.
If possible, could you write into the macro to look for a name twice, since I do have duplicates?
It should put the duplicate name and its corresponding value in the same sheet.
Works like a charm. Thanks.
If possible, could you write into the macro to look for a name twice, since I do have duplicates?
It should put the duplicate name and its corresponding value in the same sheet.
Expert: FamousMortimer replied at 2024-07-18 09:31:50
Here is a working example. The one thing I was not sure of is how do you want to handle the possibility that multiple client names can be found? This example only finds the first one, deletes it, then copies the name and phone to another sheet and moves on.
Author: Bobo--just_East_of_Madison replied at 2024-07-18 09:06:37
@FamousMortimer
Hello:
The list is coming from a text file, but I can add it to another cell if it will make the process easier
Hello:
The list is coming from a text file, but I can add it to another cell if it will make the process easier
Expert: duncanb7 replied at 2024-07-18 08:47:48
You can use "Record Marco" on Excel to record what you want to do on the sheet.
The function will record all your action such as, writing cell formaul, dragging the cell, put
the formula on cell, putting chart on the sheet.....etc. that will be recorded and saved into
your sheet's macro on VBA editor.
So you just copy it from the VBA macro record code and do some code improvement
to solve all problem. Check this record macro on Excel tutorial at
http://www.youtube.com/watch?v=nvWpFdo7EO0
Duncan
The function will record all your action such as, writing cell formaul, dragging the cell, put
the formula on cell, putting chart on the sheet.....etc. that will be recorded and saved into
your sheet's macro on VBA editor.
So you just copy it from the VBA macro record code and do some code improvement
to solve all problem. Check this record macro on Excel tutorial at
http://www.youtube.com/watch?v=nvWpFdo7EO0
Duncan
Expert: FamousMortimer replied at 2024-07-18 08:42:12
Hi,
Where does the list come from that you need to look up? Is it on another sheet, a text file, etc.?
Where does the list come from that you need to look up? Is it on another sheet, a text file, etc.?