LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 113
Default Shifting Data Right Within A Range

I needed a macro to shift data within a range incrementally to the left, one column at a time. The code below was provided by Wouter HM, for which I am extremely grateful.

=========================================
Sub ShiftLeftInRange()
Dim intCol As Long
Dim celLoop As Range
'
'determen the last used column number
intCol = Range("testRange").Columns.Count + Range("testrange").Column - 1

For Each celLoop In Range("testRange")
If celLoop.Column < intCol Then
' Shift cells witnin range 1 column to the left
celLoop.Value = celLoop.Offset(0, 1).Value
Else
' clear cel in last used column
celLoop.ClearContents
End If
Next
End Sub
=========================================

The above code works great. BUT...

1. How do I also get these same values to shift to the right? And

2. After selecting either a €śright shift€ť or €śleft shift€ť of data, how can I loop through a list of desired ranges (about 10 in total, all of which are "range named") in my workbook (containing about 7 worksheets) that I need to apply this procedure to?

Can anyone help me finish my task?

Thank you very much in advance,
Dan

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data entered in one record is shifting to others shekpatrick New Users to Excel 1 December 30th 08 07:51 PM
Shifting Data Points cyatkins Charts and Charting in Excel 1 December 5th 07 07:46 PM
shifting of data to fill into blank cells tikchye_oldLearner57 Excel Discussion (Misc queries) 6 April 11th 07 11:02 PM
Shifting Date from all data on one row to several rows ChuckW Excel Discussion (Misc queries) 1 June 8th 05 07:56 PM
Automatically shifting data, part II S. Stone Excel Worksheet Functions 0 May 5th 05 09:05 PM


All times are GMT +1. The time now is 05:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"