View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default New to vba trying to assign # to strings

I think this is what you are asking

i = 0
For Each cell In Range("H10:DD2567")
If cell.Value = "Pack" Then
i = i+1
For j = 1 To 8
If cell.Offset(0,j).Address < "F5" Then
cell.Offset(0,j).Value = "Pack" & CStr(i)
End If
Next j
IF i 40 i = 0
End If
Next cell


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"hotherps " wrote in message
...
That worked great Bob! I'm really going to have to look at it to try and
figure out exactly what is happening.
Let me ask one more question. Let's say that I do not want the same
Pack number in any given column. i.e. Col F, Row 5 = Pack1 I do not
want any more cells in Col F to be pack Pack1 instead Increment the
number

I'm thinking an If statement somewhere in there would do it? But how to
phrase it?


Bob Phillips wrote:
*Untested.

i = 0
For Each cell In Range("H10:DD2567")
If cell.Value = "Pack" Then
i = i+1
For j = 1 To 8
cell.Offset(0,j).Value = "Pack" & CStr(i)
Next j
IF i 40 i = 0
End If
Next cell

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"hotherps " wrote in
message
...
I think what I am trying to do is not that difficult, but I just

can't
get it. I have a spreadsheet with a range of H:10 to DD:267 the

work
"Pack" appears it is an assignment. I amtry to number each

occurence of
"Pack" i.e. Pack1, Pack2 up to Pack41. When the code finds the word

I
want it to fill in the next 8 cells to the right with the name Pack

and
the incremented number. It should loop through all of the rows
repeating the same pattern until it reachs Pack41, it should then

start
over at Pack1 and continue to loop to the end of the range.

Is this very complicated? I'm trying for...next, do until...

nothing
works

Thanks

Attachment filename: numberpack.xls
Download attachment:

http://www.excelforum.com/attachment.php?postid=411038
---
Message posted from http://www.ExcelForum.com/
* :D



---
Message posted from http://www.ExcelForum.com/