View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Sam Lambson Sam Lambson is offline
external usenet poster
 
Posts: 4
Default 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