ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   if then nested in a for next ?? (https://www.excelbanter.com/excel-programming/419025-if-then-nested-next.html)

pls123

if then nested in a for next ??
 
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

JLGWhiz

if then nested in a for next ??
 
Try it with: c.Formula =
instead of: c.Value =

"pls123" wrote:

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


Tom Hutchins

if then nested in a for 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

"pls123" wrote:

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


Don Guillett

if then nested in a for next ??
 
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
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"pls123" wrote in message
...
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



pls123

if then nested in a for next ??
 
hi all ty for help !!
tom's solution works fine when i delete this

Dim c As Range

tty !! byy

"pls123" wrote:

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



All times are GMT +1. The time now is 02:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com