Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old August 11th, 2003, 10:30 AM
jon145 jon145 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 4 jon145 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Excel macro

Hi all,

Complete beginner, so if this is really obvious to someone could they please help out!

I have a spreadsheet comprising say 100 blocks of repeating data each of 300 variables. This data is all contained in one huge column (this is how the data is written as text file by other software).

Using:

Sub test2()
'
'
For x = 1 To 100
' Range("A1:A300").Select
Selection.Cut
Range("B1").Select
ActiveSheet.Paste
Range("A1:A300").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
Next x

End Sub

I want to cut each block out of the primary column and paste it in another column alongside (Line 4 above). But I want to cut the next block and paste that to column C, then D, E, F, etc.
How can I do this?
When I tried before (wrongly!!) it all went nuts and if I leave it in the form above it simply overwrites all the data into column B.

Cheers, Jon.

Reply With Quote
  #2  
Old August 11th, 2003, 10:35 AM
jon145 jon145 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 4 jon145 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
perhaps this should have gone in the "Beginners" forum

oops..................

Jon.

Reply With Quote
  #3  
Old August 12th, 2003, 02:55 AM
Silian's Avatar
Silian Silian is offline
Gogga
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 198 Silian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
If I understand correctly, you want the information that is in A2 to go to B1, the information in A3 to C1, A4 to D1, etc.

If this is what you are trying 2 achieve, you must remember that there are less columns than there are rows. If not, sorry. (I have a knack 4 misunderstanding people - Try explain in a way I can understand )

Try the following untested code:

Code:
dim i
for i = 2 to 100
  cells(1, i).value = cells(i, 1).value
  cells(i, 1).value = ""
next i


(I like the cells object much more than the range object, bcs you specify the rows (in integer, like you usually do), but the column is also specified as an integer, and not as a "B" or something like that. e.g. Cells(1, 5) will be the same as range("E1") )

Reply With Quote
  #4  
Old August 12th, 2003, 03:38 AM
jon145 jon145 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 4 jon145 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Perhaps should make this a little clearer (sorry for not explaining properly before!)

I am trying to extract data from cells A1:A300 and paste in B1:B300, then delete original A1:a300.

Then I want to move data from A301:A600 to C1:C300; A601:A900 to D1300, and so on until all 100 blocks (30,000 data points) have been moved into 100 separate columns.

Hope this makes a bit more sense.

Jon.

Reply With Quote
  #5  
Old August 12th, 2003, 04:15 AM
Silian's Avatar
Silian Silian is offline
Gogga
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 198 Silian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Sorry. Told you I'm clueless Try this (You should modify it a bit 4 your use)

Code:
Dim i
Dim bContinue
Dim iConst
iConst = 10
bContinue = True
i = 1
While bContinue
    Range("A" & i & ":A" & (i + (iConst - 1))).Select
    Selection.Cut
    Cells(1, 1 + (i + iConst) \ iConst).Select
    ActiveSheet.Paste
    i = i + iConst
    If Cells(i, 1).Value = "" Then
        bContinue = False
    End If
Wend


Hope I got it right this time!

Reply With Quote
  #6  
Old August 12th, 2003, 09:07 AM
jon145 jon145 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 4 jon145 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up

Thats worked really well!!

Cheers!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Excel macro


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway