Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Looping thru all rows with instr() test


Hi,

I'm a VB6 developer, but I am battling to get to grips with this. I
have a spreadsheet with two columns (A & B). In column A, is a folder
name, embedded in which is the user name and in column B, is an amount.


I need to loop for all rows, and starting in a fixed position in column
A, derive the user name and put that in column C. However, the username
is not fixed length.

Can someone PLEASE help as I have been trying for a good few hours and
not getting very far.

Thanking you!


--
Silvertip
------------------------------------------------------------------------
Silvertip's Profile: http://www.excelforum.com/member.php...o&userid=28456
View this thread: http://www.excelforum.com/showthread...hreadid=480586

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Looping thru all rows with instr() test

Need more info: What is the format of the folder name and what is the
standard form of the user name. In other words, given that you begin looking
in a fixed position, what logic can be followed to find the end of the user
name?
--
- K Dales


"Silvertip" wrote:


Hi,

I'm a VB6 developer, but I am battling to get to grips with this. I
have a spreadsheet with two columns (A & B). In column A, is a folder
name, embedded in which is the user name and in column B, is an amount.


I need to loop for all rows, and starting in a fixed position in column
A, derive the user name and put that in column C. However, the username
is not fixed length.

Can someone PLEASE help as I have been trying for a good few hours and
not getting very far.

Thanking you!


--
Silvertip
------------------------------------------------------------------------
Silvertip's Profile: http://www.excelforum.com/member.php...o&userid=28456
View this thread: http://www.excelforum.com/showthread...hreadid=480586


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default Looping thru all rows with instr() test

In C2 enter =MID(A2,12,LEN(A2)-11)
and copy down

where the 12 above is the starting position (unchanging) and the 11 is
1character Less (12-1).

HTH
Jim


"Silvertip" wrote
in message ...

Hi,

I'm a VB6 developer, but I am battling to get to grips with this. I
have a spreadsheet with two columns (A & B). In column A, is a folder
name, embedded in which is the user name and in column B, is an amount.


I need to loop for all rows, and starting in a fixed position in column
A, derive the user name and put that in column C. However, the username
is not fixed length.

Can someone PLEASE help as I have been trying for a good few hours and
not getting very far.

Thanking you!


--
Silvertip
------------------------------------------------------------------------
Silvertip's Profile:
http://www.excelforum.com/member.php...o&userid=28456
View this thread: http://www.excelforum.com/showthread...hreadid=480586



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Looping thru all rows with instr() test

in xl2k and higher, there is a split function that can separate text into its
pieces (based on a delimiter).

If your path is always the same format:

x:\path\path\path\username\path\path\path

you could split the string and pick out the 4th component:

dim myStr as string
dim myArr as variant
dim myName as string
mystr = "x:\path\path\path\username\path\path\path"
myarr= split(mystr,"\")
myname = myarr(4)
msgBox myName





Silvertip wrote:

Hi,

I'm a VB6 developer, but I am battling to get to grips with this. I
have a spreadsheet with two columns (A & B). In column A, is a folder
name, embedded in which is the user name and in column B, is an amount.

I need to loop for all rows, and starting in a fixed position in column
A, derive the user name and put that in column C. However, the username
is not fixed length.

Can someone PLEASE help as I have been trying for a good few hours and
not getting very far.

Thanking you!

--
Silvertip
------------------------------------------------------------------------
Silvertip's Profile: http://www.excelforum.com/member.php...o&userid=28456
View this thread: http://www.excelforum.com/showthread...hreadid=480586


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Looping thru all rows with instr() test


Filename User
Field3
winamp3_0-full.exe Z:\Data\Users\ashcrofn\data\
3510536
moons.mp3 Z:\Data\Users\ashcrofn\My music\ 3571965
In Africa.mp3 Z:\Data\Users\ashcrofn\My music\ 3919289
Aerosmith Z:\Data\Users\ashcrofn\My music\ 4757504

Hi Dave,

I like the method that you utilise for extracting the name out of the
user column as it should work.

Included in the sample source that you gave me, bearing in mind the
sample data above, how do I:-

loop for all rows in the dataset ?
Take the value from the array and write it into another column on the
same row, for all rows ie as I loop ?

Many thanks.


--
Silvertip
------------------------------------------------------------------------
Silvertip's Profile: http://www.excelforum.com/member.php...o&userid=28456
View this thread: http://www.excelforum.com/showthread...hreadid=480586



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Looping thru all rows with instr() test

It kind of looks lie the folder name is in column B. (Adjust the code if that's
wrong.)

Dim FirstRow as long
dim LastRow as long
dim iRow as long
dim myStr as string
dim myName as string

with worksheets("sheet1")
firstrow = 2 'headers in row 1???
lastrow = .cells(.rows.count,"B").end(xlup).row

for iRow = firstrow to lastrow
myStr = .cells(irow,"B").value
myname = yourroutinetosplitMYSTRintopieceshere
.cells(irow,"E").value = myName
next irow
end with




Silvertip wrote:

Filename User
Field3
winamp3_0-full.exe Z:\Data\Users\ashcrofn\data\
3510536
moons.mp3 Z:\Data\Users\ashcrofn\My music\ 3571965
In Africa.mp3 Z:\Data\Users\ashcrofn\My music\ 3919289
Aerosmith Z:\Data\Users\ashcrofn\My music\ 4757504

Hi Dave,

I like the method that you utilise for extracting the name out of the
user column as it should work.

Included in the sample source that you gave me, bearing in mind the
sample data above, how do I:-

loop for all rows in the dataset ?
Take the value from the array and write it into another column on the
same row, for all rows ie as I loop ?

Many thanks.

--
Silvertip
------------------------------------------------------------------------
Silvertip's Profile: http://www.excelforum.com/member.php...o&userid=28456
View this thread: http://www.excelforum.com/showthread...hreadid=480586


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Looping thru all rows with instr() test


I'm sorted - thanks!


--
Silvertip
------------------------------------------------------------------------
Silvertip's Profile: http://www.excelforum.com/member.php...o&userid=28456
View this thread: http://www.excelforum.com/showthread...hreadid=480586

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
looping and stopping when a condition is met - test april Excel Discussion (Misc queries) 1 October 21st 09 11:36 PM
looping through rows and columns mattguerilla Excel Discussion (Misc queries) 1 March 20th 07 05:14 PM
Calculate mean of test scores from rows of test answers RiotLoadTime Excel Discussion (Misc queries) 1 July 26th 06 05:14 PM
Looping a selection of rows Andre Kruger Excel Discussion (Misc queries) 1 December 15th 05 04:18 PM
Looping through visible rows only Rasmus[_3_] Excel Programming 1 April 10th 05 02:08 AM


All times are GMT +1. The time now is 01:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"