PDA

View Full Version : Sleeper: SHIFT OR MOVE Cells On The Right...



sal21
10-26-2004, 04:13 AM
My prob:

SHIFT OR MOVE from the right all set of cells (T U V W) if i insert in the txtbox4 a new value...

In effect during the data antry if i insert "2" in the txtbox4 shift or move from the right all set of cells (T U V W)

In the wbook are present sheet ACTUALLY and AFTER

onlyadrafter
10-26-2004, 07:43 AM
Hello,


Put this code into the ACTUALLY sheet code window


P
rivate Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column = 23 And Target.Row > 1 Then
For MY_INSERT = 1 To Target.Value
Range("T" & Target.Row).Insert (xlToRight)
Next MY_INSERT
End If
End Sub



I have assumed you want the data moved by the value entered.

sal21
10-26-2004, 08:05 AM
WOW! But when i insert a new value in the column T the set of cells must move ALWAYS from 4 column not depent from the number inserted in T...

onlyadrafter
10-26-2004, 08:51 AM
Hello,

So what you are saying is that when you enter data in COL W you want the cells in T, U, V and W to moe to the right by four columns. But in your spreadsheet column T has mode to Column Y. Which is correct?

This code moves it 5 over



Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column = 23 And Target.Row > 1 Then
Range("T" & Target.Row & ":X" & Target.Row).Insert (xlToRight)
End If
End Sub


Change the X to W for four columns.

sal21
10-26-2004, 11:29 AM
Hi, onlyadrafter (http://www.vbaexpress.com/forum/member.php?u=372) tks for suggestion but i have many difficult to insert your code in my official wbook.

The db in question are L0785_TOTALE and L0785_CDI_50

Click on yellow button CERCA

I would want to insert this code in column T of the related sheet L0785_TOTALE and L0785_CDI_50...

yuo have undrstand correclly my prob and your macro work well...

In effect when i insert a value in txtbox38 ESITO NOTE B.O.U. If in the column T is presente a number shift to left for 5 column and insert the new vlaue...

My wbook is here

http://www.gssitaly.com/l0785.zip