Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change code to select columns B:D instead of just B

Status
Not open for further replies.

APElliott

Technical User
Jul 9, 2002
165
GB
Hello,

Can anyone change the following code to select items in columns b to d instead of just b

Sub selectdiscontrg()
x = 0
For i = 1 To Range("s65536").End(xlUp).Row

If Range("s" & i).Text = "01" Then
If x < 1 Then
rgSel = &quot;B&quot; & i
Else
rgSel = rgSel & &quot;,B&quot; & i
End If
x = x + 1
Else
End If
Next i
Range(rgSel).Select
End Sub

Thankyou

Andrew
 
hi andrew

replace the existing lines with these

rgSel = &quot;B&quot; & i & &quot;:D&quot; & i
rgSel = rgSel & &quot;,B&quot; & i & &quot;:D&quot; & i

happy friday
;-) If a man says something and there are no women there to hear him, is he still wrong?
 
Have you tried this?

rgSel = &quot;B&quot; & i & &quot;:D&quot; & i

instead of the entire If below

If x < 1 Then
rgSel = &quot;B&quot; & i
Else
rgSel = rgSel & &quot;,B&quot; & i
End If

HTH

P.S. There is an Office Forum and guys there are much more experienced in Excel...

Dan
[pipe]
 
Cookin on gas!

Cheers Loomah!

Cheers Dan

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top