+ Reply to Thread
Results 1 to 10 of 10

Move data with reference to format and spaces

  1. #1
    Registered User
    Join Date
    02-21-2024
    Location
    Middx UK
    MS-Off Ver
    2003
    Posts
    24

    Move data with reference to format and spaces

    My worksheet contains tracklistings and timings within the range H1:K100. In column H is a track number. In column J is a title , and in column K is a running time for each.

    Unfortunately in some cases the timing element has become misplaced to column H.

    I'm trying to tidy these worksheet entries using VBA.

    Essentially , where the timing element has slipped into row H , it needs to be relocated to it's correct position in K.

    For example , in the attached sample :

    H9 would be moved to K8
    H13 would be moved to K12
    H20 would be moved to K19
    H22 would be moved to K21

    This being done , the cells with content would be selected and moved up to replace any empty cells and make a compact listing. Deleting empty rows would not be an option in this case , as it would affect other parts of the worksheet.

    The macro would need to search the range H1:K100 and make corrections it finds. The content of H1:K100 does vary from tracklisting to tracklisting , but the error pattern is always the same.

    I'm hoping someone can help with some code to satisfy this.

    The attached sample gives a 'before and after' position in the two tabs by way of example.

    Grateful for any advice.
    Attached Files Attached Files
    Last edited by CaMeSuffit; 03-19-2024 at 12:45 AM.
    Currently using Access , Word and Excel 2003

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Move data with reference to format and spaces

    try
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-21-2024
    Location
    Middx UK
    MS-Off Ver
    2003
    Posts
    24

    Re: Move data with reference to format and spaces

    jindon - many thanks. This does the job.

    There is one small thing though. It's leaving in place the last timing in column H , when it should delete it. In the case of the sample file above it's H19 , but this could vary of course with different data.

    Can the code be modified to accommodate this?


  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Move data with reference to format and spaces

    Try change
    Please Login or Register  to view this content.
    To
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-21-2024
    Location
    Middx UK
    MS-Off Ver
    2003
    Posts
    24

    Re: Move data with reference to format and spaces

    Thanks jindon

  6. #6
    Registered User
    Join Date
    02-21-2024
    Location
    Middx UK
    MS-Off Ver
    2003
    Posts
    24

    Re: Move data with reference to format and spaces

    BTW - I was wondering if empty rows in H:K could be overwritten by moving cells in H:K with content *up* rather than deleting the whole row. Deleting the row does cause issues elsewhere in the worksheet.

    So for example

    Row H I J K
    23 1 2 2 2
    24 2 3 6 8
    25
    26 5 6 7 8
    27
    28 2 3 3 7

    Would become

    Row H I J K
    23 1 2 2 2
    24 2 3 6 8
    25 5 6 7 8
    26 2 3 3 7

    without deleting rows 25 & 27

    Grateful for any advice

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Move data with reference to format and spaces

    Is it related to your original question?

    I need to see the source data and the result in worksheet.

  8. #8
    Registered User
    Join Date
    02-21-2024
    Location
    Middx UK
    MS-Off Ver
    2003
    Posts
    24

    Re: Move data with reference to format and spaces

    Thanks jindon. yes , it's related to the same project. The issue is where other text or formulas in A:G are being deleted because they are on the same row as affected rows in H:I.

    The formulas change to accommodate the delete , but other data and content is entirely deleted by the macro. I'll attach a modified sample.

    If you run the 'test' macro I hope you can see the effect on rows 1 - 3 .

    Very grateful for your time and expertise.
    Attached Files Attached Files
    Last edited by CaMeSuffit; 03-21-2024 at 12:31 AM.

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Move data with reference to format and spaces

    Do you want to delete only col.H:K?
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    02-21-2024
    Location
    Middx UK
    MS-Off Ver
    2003
    Posts
    24

    Re: Move data with reference to format and spaces

    jindon - perfect solution. Many thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. how do I format a cell reference to move as source changes
    By KGray in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 PM
  2. [SOLVED] how do I format a cell reference to move as source changes
    By KGray in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 PM
  3. [SOLVED] how do I format a cell reference to move as source changes
    By Vasant Nanavati in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 02:05 PM
  4. how do I format a cell reference to move as source changes
    By KGray in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  5. how do I format a cell reference to move as source changes
    By KGray in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 11:05 AM
  6. how do I format a cell reference to move as source changes
    By KGray in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  7. how do I format a cell reference to move as source changes
    By KGray in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  8. [SOLVED] how do I format a cell reference to move as source changes
    By KGray in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-12-2005, 08:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1