ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Can I do Excel formula that variably shifts columns right or left (https://www.excelbanter.com/excel-discussion-misc-queries/210372-can-i-do-excel-formula-variably-shifts-columns-right-left.html)

siteguy

Can I do Excel formula that variably shifts columns right or left
 
I need to learn how to shift data right or left in columns based upon an
input. For instance, let's say I take 10 orders in January. I have a
constant value that assumes it will take me 4 months to build them. I then
want to show 10 sales in May (4 months after order). If I change the
manufacturing assumption to 3 months, I want the 10 sales to reflect in
April, one column to the left.

Sam Lambson

Can I do Excel formula that variably shifts columns right or left
 
On Nov 14, 1:08*pm, siteguy wrote:
I need to learn how to shift data right or left in columns based upon an
input. *For instance, let's say I take 10 orders in January. *I have a
constant value that assumes it will take me 4 months to build them. *I then
want to show 10 sales in May (4 months after order). *If I change the
manufacturing assumption to 3 months, I want the 10 sales to reflect in
April, one column to the left.


In VBA, you can access a column with Columns property. The following
code is a Sub that would take the values from a source column (source)
and put them into a destination column (dest).

Sub moveColumn(source As Integer, dest As Integer)

ActiveSheet.Columns(source).Value = ActiveSheet.Columns
(dest).Value
ActiveSheet.Columns(source).Delete

End Sub


All times are GMT +1. The time now is 08:47 PM.

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