PC Review


Reply
Thread Tools Rate Thread

automaticaly moving information

 
 
J
Guest
Posts: n/a
 
      9th Apr 2008
I am importing CSV records from a sales management application and the
information, when imported, hits the sheet in the columns and each range
needs to be moved into the correct columns. (This imported information is of
a different size each time it is imported. )

Also, there will be several ranges of records that will have to be moved
under the same identified column.

Example:

move I2 thru M2 to D2
move N2 thru R2 to D3
move S2 thru W2 to D4 (and so on until it finds the last record with the
same import code)

I have identified the columns that this information needs to be moved into,
however I do not know the formula or code to tell it to do this?

Can anyone help me? Thanks, J.


 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      9th Apr 2008
I think the problem is with your input data. the data may have been created
on a unix system that uses a different Line feed. Your problem may be all
the data is ending up on one line because it is not recognizing the carriage
return. If this is the case I have a better solution which is to read the
data into the worksheet using a macro that will recognized the UNIX carriage
return.

"J" wrote:

> I am importing CSV records from a sales management application and the
> information, when imported, hits the sheet in the columns and each range
> needs to be moved into the correct columns. (This imported information is of
> a different size each time it is imported. )
>
> Also, there will be several ranges of records that will have to be moved
> under the same identified column.
>
> Example:
>
> move I2 thru M2 to D2
> move N2 thru R2 to D3
> move S2 thru W2 to D4 (and so on until it finds the last record with the
> same import code)
>
> I have identified the columns that this information needs to be moved into,
> however I do not know the formula or code to tell it to do this?
>
> Can anyone help me? Thanks, J.
>
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      9th Apr 2008
If Joel's guess if wrong, then for the example you posted, this macro will
move the row of data to the column you specified...

Sub MoveRow2Data()
Dim X As Long, Z As Long
Dim LastColumn As Long
Const StartCol As Long = 9
Const GroupCount As Long = 5
Const MoveToColumn As Long = 4
Const DataRow As Long = 2
With Worksheets("Sheet1")
LastColumn = .Cells(DataRow, .Columns.Count).End(xlToLeft).Column
For X = StartCol To LastColumn Step 5
For Z = 0 To GroupCount - 1
.Cells(DataRow, X + Z).Copy _
Destination:=.Cells(X - 9 + DataRow + Z, MoveToColumn)
Next
Next
.Cells(DataRow, StartCol).Resize(1, LastColumn - _
StartCol + 1).ClearContents
End With
End Sub

Rick


"J" <(E-Mail Removed)> wrote in message
news:6095B719-99FF-4E5D-B222-(E-Mail Removed)...
>I am importing CSV records from a sales management application and the
> information, when imported, hits the sheet in the columns and each range
> needs to be moved into the correct columns. (This imported information is
> of
> a different size each time it is imported. )
>
> Also, there will be several ranges of records that will have to be moved
> under the same identified column.
>
> Example:
>
> move I2 thru M2 to D2
> move N2 thru R2 to D3
> move S2 thru W2 to D4 (and so on until it finds the last record with the
> same import code)
>
> I have identified the columns that this information needs to be moved
> into,
> however I do not know the formula or code to tell it to do this?
>
> Can anyone help me? Thanks, J.
>
>


 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      9th Apr 2008
Rick: I think you have to insert rows otherwise you are going to overwrite
data in next row. I posted this solution in a newer posting.

"Rick Rothstein (MVP - VB)" wrote:

> If Joel's guess if wrong, then for the example you posted, this macro will
> move the row of data to the column you specified...
>
> Sub MoveRow2Data()
> Dim X As Long, Z As Long
> Dim LastColumn As Long
> Const StartCol As Long = 9
> Const GroupCount As Long = 5
> Const MoveToColumn As Long = 4
> Const DataRow As Long = 2
> With Worksheets("Sheet1")
> LastColumn = .Cells(DataRow, .Columns.Count).End(xlToLeft).Column
> For X = StartCol To LastColumn Step 5
> For Z = 0 To GroupCount - 1
> .Cells(DataRow, X + Z).Copy _
> Destination:=.Cells(X - 9 + DataRow + Z, MoveToColumn)
> Next
> Next
> .Cells(DataRow, StartCol).Resize(1, LastColumn - _
> StartCol + 1).ClearContents
> End With
> End Sub
>
> Rick
>
>
> "J" <(E-Mail Removed)> wrote in message
> news:6095B719-99FF-4E5D-B222-(E-Mail Removed)...
> >I am importing CSV records from a sales management application and the
> > information, when imported, hits the sheet in the columns and each range
> > needs to be moved into the correct columns. (This imported information is
> > of
> > a different size each time it is imported. )
> >
> > Also, there will be several ranges of records that will have to be moved
> > under the same identified column.
> >
> > Example:
> >
> > move I2 thru M2 to D2
> > move N2 thru R2 to D3
> > move S2 thru W2 to D4 (and so on until it finds the last record with the
> > same import code)
> >
> > I have identified the columns that this information needs to be moved
> > into,
> > however I do not know the formula or code to tell it to do this?
> >
> > Can anyone help me? Thanks, J.
> >
> >

>
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      9th Apr 2008
I didn't get the impression this was being done in an already populated
column (mainly because the example showed the starting row as 2); but, of
course, given the example nature of the message, you could very well be
right.

Rick


"Joel" <(E-Mail Removed)> wrote in message
newsC2B7D45-EC4B-4A28-B202-(E-Mail Removed)...
> Rick: I think you have to insert rows otherwise you are going to overwrite
> data in next row. I posted this solution in a newer posting.
>
> "Rick Rothstein (MVP - VB)" wrote:
>
>> If Joel's guess if wrong, then for the example you posted, this macro
>> will
>> move the row of data to the column you specified...
>>
>> Sub MoveRow2Data()
>> Dim X As Long, Z As Long
>> Dim LastColumn As Long
>> Const StartCol As Long = 9
>> Const GroupCount As Long = 5
>> Const MoveToColumn As Long = 4
>> Const DataRow As Long = 2
>> With Worksheets("Sheet1")
>> LastColumn = .Cells(DataRow, .Columns.Count).End(xlToLeft).Column
>> For X = StartCol To LastColumn Step 5
>> For Z = 0 To GroupCount - 1
>> .Cells(DataRow, X + Z).Copy _
>> Destination:=.Cells(X - 9 + DataRow + Z, MoveToColumn)
>> Next
>> Next
>> .Cells(DataRow, StartCol).Resize(1, LastColumn - _
>> StartCol + 1).ClearContents
>> End With
>> End Sub
>>
>> Rick
>>
>>
>> "J" <(E-Mail Removed)> wrote in message
>> news:6095B719-99FF-4E5D-B222-(E-Mail Removed)...
>> >I am importing CSV records from a sales management application and the
>> > information, when imported, hits the sheet in the columns and each
>> > range
>> > needs to be moved into the correct columns. (This imported information
>> > is
>> > of
>> > a different size each time it is imported. )
>> >
>> > Also, there will be several ranges of records that will have to be
>> > moved
>> > under the same identified column.
>> >
>> > Example:
>> >
>> > move I2 thru M2 to D2
>> > move N2 thru R2 to D3
>> > move S2 thru W2 to D4 (and so on until it finds the last record with
>> > the
>> > same import code)
>> >
>> > I have identified the columns that this information needs to be moved
>> > into,
>> > however I do not know the formula or code to tell it to do this?
>> >
>> > Can anyone help me? Thanks, J.
>> >
>> >

>>
>>


 
Reply With Quote
 
J
Guest
Posts: n/a
 
      10th Apr 2008
Hi Rick and Joel,

I appreciate your help and I guess my explanation wasn't completely clear,
so I will try it again and hopefully I won't make it worse.

The Imported CSV information will be going onto and overwriting any existing
information already on the sheet. And this is expected and it's ok because
when the initial search query is done within the sales-management
application, the search is always based on a new "date", so the information
on the spreadsheet needs to be replaced.

I am going to try the macro that you gave me, but it's been a very long time
since I programmed code, so if you can give me any pointers that would be
appreciated.

Thanks J.

"Rick Rothstein (MVP - VB)" wrote:

> I didn't get the impression this was being done in an already populated
> column (mainly because the example showed the starting row as 2); but, of
> course, given the example nature of the message, you could very well be
> right.
>
> Rick
>
>
> "Joel" <(E-Mail Removed)> wrote in message
> newsC2B7D45-EC4B-4A28-B202-(E-Mail Removed)...
> > Rick: I think you have to insert rows otherwise you are going to overwrite
> > data in next row. I posted this solution in a newer posting.
> >
> > "Rick Rothstein (MVP - VB)" wrote:
> >
> >> If Joel's guess if wrong, then for the example you posted, this macro
> >> will
> >> move the row of data to the column you specified...
> >>
> >> Sub MoveRow2Data()
> >> Dim X As Long, Z As Long
> >> Dim LastColumn As Long
> >> Const StartCol As Long = 9
> >> Const GroupCount As Long = 5
> >> Const MoveToColumn As Long = 4
> >> Const DataRow As Long = 2
> >> With Worksheets("Sheet1")
> >> LastColumn = .Cells(DataRow, .Columns.Count).End(xlToLeft).Column
> >> For X = StartCol To LastColumn Step 5
> >> For Z = 0 To GroupCount - 1
> >> .Cells(DataRow, X + Z).Copy _
> >> Destination:=.Cells(X - 9 + DataRow + Z, MoveToColumn)
> >> Next
> >> Next
> >> .Cells(DataRow, StartCol).Resize(1, LastColumn - _
> >> StartCol + 1).ClearContents
> >> End With
> >> End Sub
> >>
> >> Rick
> >>
> >>
> >> "J" <(E-Mail Removed)> wrote in message
> >> news:6095B719-99FF-4E5D-B222-(E-Mail Removed)...
> >> >I am importing CSV records from a sales management application and the
> >> > information, when imported, hits the sheet in the columns and each
> >> > range
> >> > needs to be moved into the correct columns. (This imported information
> >> > is
> >> > of
> >> > a different size each time it is imported. )
> >> >
> >> > Also, there will be several ranges of records that will have to be
> >> > moved
> >> > under the same identified column.
> >> >
> >> > Example:
> >> >
> >> > move I2 thru M2 to D2
> >> > move N2 thru R2 to D3
> >> > move S2 thru W2 to D4 (and so on until it finds the last record with
> >> > the
> >> > same import code)
> >> >
> >> > I have identified the columns that this information needs to be moved
> >> > into,
> >> > however I do not know the formula or code to tell it to do this?
> >> >
> >> > Can anyone help me? Thanks, J.
> >> >
> >> >
> >>
> >>

>
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      10th Apr 2008
> I am going to try the macro that you gave me, but it's been a very long
> time
> since I programmed code, so if you can give me any pointers that would be
> appreciated.


Right click the worksheet tab that you want this functionality on, select
View Code from the menu that pops up and Copy/Paste my macro into the window
that opened up when you did that. Next, back on the worksheet, after your
CSV file is imported into cell I2 through whatever column it end at, press
Alt+F8, select MoveRow2Data from the list and click Run. That should be it
(assuming I didn't screw up the code in my macro or that I didn't
misinterpret your question).

Rick

 
Reply With Quote
 
J
Guest
Posts: n/a
 
      10th Apr 2008
HI Rick

I copy and pasted the macro but when I ran it I got a syntex error.

Do my my ranges have to be noted on in the macro?

My ranges are:

I2 thru M2 inserted unter D3
N2 thru R2 inserted under D4
S2 thru W2 inserted under D5

And so on ....

I will be putting a math formula at the bottom of the D column when all of
the info has be moved into place.

I hope this makes more sense?

If so, would you tell me how to modify the macro?

Thanks, J.
"Rick Rothstein (MVP - VB)" wrote:

> > I am going to try the macro that you gave me, but it's been a very long
> > time
> > since I programmed code, so if you can give me any pointers that would be
> > appreciated.

>
> Right click the worksheet tab that you want this functionality on, select
> View Code from the menu that pops up and Copy/Paste my macro into the window
> that opened up when you did that. Next, back on the worksheet, after your
> CSV file is imported into cell I2 through whatever column it end at, press
> Alt+F8, select MoveRow2Data from the list and click Run. That should be it
> (assuming I didn't screw up the code in my macro or that I didn't
> misinterpret your question).
>
> Rick
>
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      10th Apr 2008
What line did you get the "syntax error" on? By the way, I just re-ran the
code here on my system without any problem at all. I am using XL2003... what
version are you using? Out of curiosity, did you remember to change the
Worksheets("Sheet1") reference in the With statement to the name of your
actual sheet?

Rick


"J" <(E-Mail Removed)> wrote in message
news:89BE2CFA-A8C0-4C97-834B-(E-Mail Removed)...
> HI Rick
>
> I copy and pasted the macro but when I ran it I got a syntex error.
>
> Do my my ranges have to be noted on in the macro?
>
> My ranges are:
>
> I2 thru M2 inserted unter D3
> N2 thru R2 inserted under D4
> S2 thru W2 inserted under D5
>
> And so on ....
>
> I will be putting a math formula at the bottom of the D column when all of
> the info has be moved into place.
>
> I hope this makes more sense?
>
> If so, would you tell me how to modify the macro?
>
> Thanks, J.
> "Rick Rothstein (MVP - VB)" wrote:
>
>> > I am going to try the macro that you gave me, but it's been a very long
>> > time
>> > since I programmed code, so if you can give me any pointers that would
>> > be
>> > appreciated.

>>
>> Right click the worksheet tab that you want this functionality on, select
>> View Code from the menu that pops up and Copy/Paste my macro into the
>> window
>> that opened up when you did that. Next, back on the worksheet, after your
>> CSV file is imported into cell I2 through whatever column it end at,
>> press
>> Alt+F8, select MoveRow2Data from the list and click Run. That should be
>> it
>> (assuming I didn't screw up the code in my macro or that I didn't
>> misinterpret your question).
>>
>> Rick
>>
>>


 
Reply With Quote
 
J
Guest
Posts: n/a
 
      10th Apr 2008
Rick,

I'm using Excel 2000 and, yes, I changed the sheet name to the one that I
have renamed it too.

Also, here's the error:

Compile error
Syntax Error

And the first line is highlighted in Yellow with the second line highlighted
in Blue,

Thanks,


"Rick Rothstein (MVP - VB)" wrote:

> What line did you get the "syntax error" on? By the way, I just re-ran the
> code here on my system without any problem at all. I am using XL2003... what
> version are you using? Out of curiosity, did you remember to change the
> Worksheets("Sheet1") reference in the With statement to the name of your
> actual sheet?
>
> Rick
>
>
> "J" <(E-Mail Removed)> wrote in message
> news:89BE2CFA-A8C0-4C97-834B-(E-Mail Removed)...
> > HI Rick
> >
> > I copy and pasted the macro but when I ran it I got a syntex error.
> >
> > Do my my ranges have to be noted on in the macro?
> >
> > My ranges are:
> >
> > I2 thru M2 inserted unter D3
> > N2 thru R2 inserted under D4
> > S2 thru W2 inserted under D5
> >
> > And so on ....
> >
> > I will be putting a math formula at the bottom of the D column when all of
> > the info has be moved into place.
> >
> > I hope this makes more sense?
> >
> > If so, would you tell me how to modify the macro?
> >
> > Thanks, J.
> > "Rick Rothstein (MVP - VB)" wrote:
> >
> >> > I am going to try the macro that you gave me, but it's been a very long
> >> > time
> >> > since I programmed code, so if you can give me any pointers that would
> >> > be
> >> > appreciated.
> >>
> >> Right click the worksheet tab that you want this functionality on, select
> >> View Code from the menu that pops up and Copy/Paste my macro into the
> >> window
> >> that opened up when you did that. Next, back on the worksheet, after your
> >> CSV file is imported into cell I2 through whatever column it end at,
> >> press
> >> Alt+F8, select MoveRow2Data from the list and click Run. That should be
> >> it
> >> (assuming I didn't screw up the code in my macro or that I didn't
> >> misinterpret your question).
> >>
> >> Rick
> >>
> >>

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Free Moving Estimate, Local Movers, Long Distance Moving, PackingSupplies, Storage Rental, Home Moving, Apartment Moving, Office Moving,Commercial Moving linkswanted Microsoft ASP .NET 0 6th Jan 2008 04:45 AM
Moving Data Automaticaly JohnM Microsoft Excel New Users 3 25th Nov 2007 08:23 PM
Mouse pointer moving automaticaly intermittently =?Utf-8?B?UGVlcHk=?= Windows XP General 7 18th May 2007 02:55 PM
how do i can send a information of cell automaticaly via email? =?Utf-8?B?UmFqYW5p?= Microsoft Excel New Users 1 8th Jun 2006 10:59 PM
Re: Moving Information Jack Taylor Microsoft Excel Worksheet Functions 0 5th Aug 2003 11:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:33 PM.