Can I do Excel formula that variably shifts columns right or left

S

siteguy

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.
 
S

Sam Lambson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top