![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: North Wales Coast, UK
Posts: 95
|
Evening All,
I am looking to find a Value in a list and then move along the row, say 5 cells to the right and paste a value into that cell. I have looked at a few ways of going about this but is there a 'smarter' way than considering Looping through the list of Values? Any comments, well most(!), appreciated. Cheers S |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
If you're using VBA to do this, have a look at the "Find" function in VBA help. There's a reasonable example there. It's definitely faster than looping through cells. (combine this with "Offset" and you'll be good to go)
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Location: North Wales Coast, UK
Posts: 95
|
Hi Mark,
Thank you for your swift response. I have had a look at the 'Find Method' Example in VBA Help and have, once again, discovered why I deal with Accounts rather than VBA programming! Do you happen to know of any other source of relatively easy examples and explanation so I may try to get my head around the Find Method? Thanks once again S [ This Message was edited by: Sam40mUK on 2002-04-18 15:42 ] |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Yeah, I said that the help file example was reasonable. I don't like it myself, but it's usually a decent place to start. I've knocked up an example for you and I hope it makes enough sense to get you started. I started a new workbook and on Sheet1 I put in the values 1 to 15 in column A starting in A1. I then made this code to find the value "10" and put a message in a box 5 columns to the right.
It shouldn't take too much for you to adapt it to your specific needs. (I hope). HTH |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Mar 2002
Location: North Wales Coast, UK
Posts: 95
|
Firstly thanks Mark,
I appreciate your time in sorting out a further example for me. I did spend some time looking at VBA Help and found it for a novice rather .. there you go .. take it or leave it! I am sure that others on this board will agree that a well explained example with the ability to ask, what maybe considered 'silly' questions is an immensely useful way of trying to understand Excel and glimpsing the use of VBA in the 'real world'. Thanks one again S |
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
No problems at all. I know that some parts of the help file are better than others and if it was perfect then this board wouldn't exist.
Also, I wasn't sure of your expertise and usually I don't do lazy answers, but I think I had one eye on the golf course yesterday. (additionally, we have all went through what you're going through) |
|
|
|
|
|
#7 |
|
New Member
Join Date: Apr 2002
Posts: 8
|
I really liked your example, the sTargettext you set is for a set expression, if I wanted the sTargetText to be based off a cell in another worksheet, how would that look?
sTargetText = worksheets("SheetA").[J4].Value? Range? or something like that? |
|
|
|
|
|
#8 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Quote:
I just saw your post today, you were right first time, but you may have figred that out by now:
Although personally, I don't really like using e.g. [J4] for ranges. I'm too used to using "Range" like this:
...but I have used the []'s in posts here because it's just too damned tempting to use it in a small snippet of code. |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|