Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
change of data location
unable to macro, can anybody help please
I have bunch ofdata in Excel and want: 1- to insert an empty cell in Col G start from G4, (G4 content goes one cell down etc) jump evrery 8 cell, (e.g. G12, G20 ,... up to G49181 as last cell. 2- copy data from T3 to G4, T12 to G13, T21 to G22 and continue by jumping for both T and G as 9. Last cell to copy from is T49180 and copy to G49181. Appreciate your help |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
change of data location
Darius
The key to the solving your problem seems to be to select every 8th row; insert row, select every eighth row again; copy values from row T. 1) This Microsoft code should get you started selecting rows: http://support.microsoft.com/kb/213438 Change RowsBetween = 3 To RowsBetween = 8 You will need to modify the code so it selects ranges for insert and copy as you specify below. If you work with the selection range as a parameter, you can re-use the same code for both part of the selection process. In other words, the code will start as follows: Sub SelectEveryNthRow(yourRange) ' any Dim statements Range(yourRange).Select ' Initialize ColsSelection equal to the number of columns in the ' selection. ' etc 2) Record a macro to cover insert row. If you record an insert for a single cell (say G4) it will also work on non-contiguous multi-cell selection, provided you only use the code specific to row insertion. For example, if you happen to record Range("G4").select (or similar) delete this from the recording. 3) To copy your values from column T (OTOMH and untested) Sub CopyTvalsToG() 'use after selecting blanks in row G 'in the following -1 is previous row ' 13 is 13 columns across selection.value = selection.offset(-1,13).value End Sub Note: The Microsoft code loops through cells and will be v-e-r-y s-l-o-w. So, you will need to be very patient:-( To speed things up a little, turn off screen updating and set calculations to manual. After the code runs, turn screen updating back on and rest calculations to previous value. To speed up testing, work with a smaller range of test data. Hopefully, you understand a little VBA coding and will be able to read what the Microsoft code does as you step through its execution and look at the result. If you do need help doing any of the above, please ask. -- Steve "Darius" wrote in message ... unable to macro, can anybody help please I have bunch ofdata in Excel and want: 1- to insert an empty cell in Col G start from G4, (G4 content goes one cell down etc) jump evrery 8 cell, (e.g. G12, G20 ,... up to G49181 as last cell. 2- copy data from T3 to G4, T12 to G13, T21 to G22 and continue by jumping for both T and G as 9. Last cell to copy from is T49180 and copy to G49181. Appreciate your help |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Change the location of external data feeding a pivottable | Excel Discussion (Misc queries) | |||
Change Location of VBE References with VBA | Excel Programming | |||
How do I change the default location when Importing data? | Excel Discussion (Misc queries) | |||
sort multiple columns of data but not change the data location... Possible? | Excel Programming |