if then nested in a for next ??

  • Thread starter Thread starter pls123
  • Start date Start date
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
 
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
 
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
 
hi all ty for help !!
tom's solution works fine when i delete this

Dim c As Range

tty !! byy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Code only works in Debug mode. Why? 6
Selecting sheet 2 5
Copy code failing 2
Conflict 8
Activate a Workbook 4
Code condition 3
Run-time Error: '438' 2
Converting User IDs to User Name 1

Back
Top