Shifting data to columns automatically

TC

New Member
Joined
Oct 26, 2002
Messages
5
Dear all,
I want to shift the data in some columns to others based on the entry.
For ex:If the entry is 1 then data from Column B4:F4 should be shifted to G4:K4
If entry is 2 then data from B4:F4 should be shifted to H4:L4.Depending on the entry No the shifting column increases.
I dont know how to implement this idea and request help .
Thanks in advance .
TC
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,123
do you want to do this in VB or by formula?

by VB...

SUB COPY_DATA

99

CODEENTRY = InputBox("Please Enter the Appropriate Selection Code (1 or 2)","CODE ENTRY")

If CODEENTRY = 1 THEN

Range("B4:F4").Copy
Range("G4").PasteSpecial xlPasteValues

End If

If CODEENTRY = 2 THEN

Range("B4:F4").Copy
Range("H4").PasteSpecial xlPasteValues

End If

If CODEENTRY <> 1 AND CODEENTRY <> 2 THEN

MessageBox "You Have Failed to Enter an Applicable Code (1 or 2) - Please Re-Enter",vbokonly,"ERROR"

GoTo 99

End If

End Sub


As a formula...

If say A1 = Code (1 or 2)

in G4 = IF($A$1=1,B$4,"")

(the above formula applies to G4 ONLY)

in H4 = IF($A$1=1,C$4,B$4)

Copy this formula across to K4.

in L4 = IF($A$1=1,"",F$4)

(the above formula applies to G4 ONLY)


(without testing - I think the above should work)
 

Forum statistics

Threads
1,144,329
Messages
5,723,737
Members
422,512
Latest member
MHau5

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top