LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Looping through rows and shifting certain contents

I'm pretty new to VBA, but love the few things I have been able to do
so far . . . here's what I want to do now:

I have a semi-colon delimited download from a program. I put it
through the text-import wizzard and it imports to columns almost
perfectly . . . Almost. Out of the 10,000 or so lines on the import, a
handful were not delimited properly on the data dump. This is
resulting in some of the data being shifted left either one or two
columns. (see example below of the last three columns of my data dump)

My pre-VBA solution was to filter the column AK by BLANK and then
manually shift the data to the right one or two rows (whatever it
needed). Now that I'm falling in love with VBA, i understand the time
that automating this process could save.

Here's what I'm trying to do in plain English

For each row I want to

If the contents of AJ are = 0 than do nothing,
If the contents of AJ are blank "", then I want to shift the contents
of Column T through AI two cells to the right

Then I will do a similar loop through Column AK, with the only
difference being
If the contents of AI are blank "", then I want to shift the contents
of Column U through AJ ONE cell to the right

Here's what I've tried for the Column AJ loop:

Sub MoveBadRows()
'This Sub is not good yet
Range("aj2").Select

Do While Selection.Offset(0, -1) < ""
If IsEmpty(ActiveCell) Then
Range(ActiveCell.Offset(0, -1):ActiveCell.Offset(0,
-16)).Select
Selection.Cut Destination:=ActiveCell.Offset(0,
2).Range("A1:P1")
ActiveCell.Offset(1, 0).Select

Else: ActiveCell.Offset(1, 0).Select
End If
Loop


End Sub

I know that my problems are :
1) In defining the range that is to be moved
2) Getting the active cell back a single cell in column AK

AI AJ AK
0 0 0
0
0 0 0
0 0
0 0 0
0
0 0 0
0 0
0 0 0




Note:My download always has 37 columns (AK) and varying number of rows.

Thanks!

 
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
Rows are shifting slightly when printed Matt Lauer Excel Discussion (Misc queries) 4 October 2nd 09 06:40 PM
Deleting Rows and Shifting Up - Repost D.Parker Excel Discussion (Misc queries) 14 October 11th 07 04:58 AM
Shifting rows into columns biggg_fish Excel Discussion (Misc queries) 2 March 28th 07 03:13 AM
Shifting the contents of cells MTC Setting up and Configuration of Excel 1 August 1st 06 12:10 PM
Shifting Date from all data on one row to several rows ChuckW Excel Discussion (Misc queries) 1 June 8th 05 07:56 PM


All times are GMT +1. The time now is 10:22 PM.

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

About Us

"It's about Microsoft Excel"