ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Move Cell Value to Right Using Formula (https://www.excelbanter.com/excel-worksheet-functions/133283-move-cell-value-right-using-formula.html)

[email protected]

Move Cell Value to Right Using Formula
 
I'm trying to do the following:

If A1 = 2, then starting at position C5, move 2 cells to the right and
populate with a value
If A1 = 3, then starting at position C5, move 3 cells to the right and
populate with a value
etc...

Appreciate any ideas

Thanks,
Sven


Mike

Move Cell Value to Right Using Formula
 
the cells to the right of C5 are E5 & F5 so put a formula in those cells

for E5

=IF(A1=2,"Some value","")

for F5
=IF(A1=3,"Some value","")

Mike


" wrote:

I'm trying to do the following:

If A1 = 2, then starting at position C5, move 2 cells to the right and
populate with a value
If A1 = 3, then starting at position C5, move 3 cells to the right and
populate with a value
etc...

Appreciate any ideas

Thanks,
Sven



Don Guillett

Move Cell Value to Right Using Formula
 

Best done with a worksheet_change macro using an if or selectcase statement
within

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
I'm trying to do the following:

If A1 = 2, then starting at position C5, move 2 cells to the right and
populate with a value
If A1 = 3, then starting at position C5, move 3 cells to the right and
populate with a value
etc...

Appreciate any ideas

Thanks,
Sven




Don Guillett

Move Cell Value to Right Using Formula
 
right click sheet tabview codeinsert thissee how it works and change to
suit.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column < 1 Then Exit Sub
Target.Offset(, Target.Value) = Target * Target

End Sub

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...

Best done with a worksheet_change macro using an if or selectcase
statement within

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
I'm trying to do the following:

If A1 = 2, then starting at position C5, move 2 cells to the right and
populate with a value
If A1 = 3, then starting at position C5, move 3 cells to the right and
populate with a value
etc...

Appreciate any ideas

Thanks,
Sven






Gord Dibben

Move Cell Value to Right Using Formula
 
Formulas cannot move things, only return results to the cell in which they
reside.

Either have formulas in E5 and F5 like =IF(A1=2,"value for 2","not 2")

Or go with event code.

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub
On Error GoTo endit
Application.EnableEvents = False
Select Case Target.Value

Case 2
Target.Offset(5, 4).Value = "value for 2"

Case 3
Target.Offset(5, 5).Value = "value for 3"

End Select
endit:
Application.EnableEvents = True
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code".

Copy/paste the above code into that sheet module.


Gord Dibben MS Excel MVP

On 4 Mar 2007 08:54:12 -0800, wrote:

I'm trying to do the following:

If A1 = 2, then starting at position C5, move 2 cells to the right and
populate with a value
If A1 = 3, then starting at position C5, move 3 cells to the right and
populate with a value
etc...

Appreciate any ideas

Thanks,
Sven




All times are GMT +1. The time now is 12:58 PM.

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