if then nested in a for next ??

P

pls123

Hi all i need this but it doesn't work like this... any suggestion ?? ty !!

For Each c In Selection.Cells

If Selection.Column = A Then
c.Value = "='C:\WB\[@@MYPAGE." & "-20.-20" & "." & c.Row & "." &
"11111.-11111.4" & ".xlsm]Sheet2'!$T$3"
End If
If Selection.Cells.Column = "B" Then
c.Value = "='C:\WB\[@@MYPAGE." & "-19.-19" & "." & c.Row & "." &
"11111.-11111.4" & ".xlsm]Sheet2'!$T$3"
End If
Next
 
T

Tom Hutchins

Try

Dim c As Range
For Each c In Selection
If c.Column = 1 Then
c.Value = "='C:\WB\[@@MYPAGE." & "-20.-20" & "." & c.Row & "." &
"11111.-11111.4" & ".xlsm]Sheet2'!$T$3"
End If
If c.Column = 2 Then
c.Value = "='C:\WB\[@@MYPAGE." & "-19.-19" & "." & c.Row & "." &
"11111.-11111.4" & ".xlsm]Sheet2'!$T$3"
End If
Next

Hope this helps,

Hutch
 
D

Don Guillett

You had col=A instead of col ="A"

try this instead

sub checkcol()
mv= 21 - c.Column

For Each c In Selection.Cells
c.Value = "='C:\WB\[@@MYPAGE." & "-" & mv & ".-" & mv & " & "." & c.Row &
"." &
"11111.-11111.4" & ".xlsm]Sheet2'!$T$3"
Next c
end sub
 
P

pls123

hi all ty for help !!
tom's solution works fine when i delete this

Dim c As Range

tty !! byy
 
Top