View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default New to vba trying to assign # to strings

Sub Button2_Click()
Dim i As Integer, k as integer, j as integer
Dim intcounter As Integer
Dim varr, varr1
Dim cell as Range
varr = Array("PACK","LVD")
varr1 = Array(40,8)
for k = lbound(varr) to ubound(varr)
intcounter = 0
For Each cell In Range("A1:DD267")
If cell.Value = varr(k) Then
intcounter = intcounter + 1
For j = 0 To 7
if varr(k) = "PACK" Then
cell.Offset(0, j).Value = "PACK" & intcounter
else
cell.offset(0,j).Value = varr(k)
end if
Next j
If intcounter varr(k) Then intcounter = 0
End If
Next cell
Next k
End Sub

But I am not sure what the point of using a count on items other than PACK
serves.

Add values to the two arrays (varr, varr1)

--
Regards,
Tom Ogilvy


hotherps wrote in message
...
Here is the code at the moment :Sub Button1_Click()
Dim i As Integer

i = 0
For Each cell In Range("A1:DD267")
If cell.Value = "PACK" Then
i = i + 1
For j = 0 To 7
cell.Offset(0, j).Value = "Pack" & CStr(i)
Next j
If i 40 Then i = 0
End If
Next cell

End Sub
Sub Button2_Click()
Dim i As Integer
Dim intcounter As Integer

intcounter = 0
For Each cell In Range("A1:DD267")
If cell.Value = "LVD" Then
intcounter = intcounter + 1
For j = 0 To 7
cell.Offset(0, j).Value = "LVD" & intcounter
Next j
If intcounter 8 Then intcounter = 0
End If
Next cell
End Sub


I'm using two command buttons two start the code. I'd like to be able
to consolidate these actions together. I also have other codes that I
would like the same result for. However I want to hide the counter on
every task other than "Pack"


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