Results 1 to 6 of 6
  1. #1
    lccrews is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Location
    Los Angeles
    Posts
    194

    Having Trouble Lining Up Columns

    Please have a look at my screenshots. This is really hard for me to articulate which is probably why I'm having a hard time with the solution. I have code in access to export two crosstab queries to two sections of an excel sheet. The problem is, the information in yellow doesn't line up with the columns. So I'm looking for a way to line them up.
    One piece of information that might be helpful: Range("C1","S1") contain values that correspond to Range("C35","I35").
    Thank you for any advice!


    Click image for larger version. 

Name:	1.jpg 
Views:	17 
Size:	176.7 KB 
ID:	35976Click image for larger version. 

Name:	2.jpg 
Views:	17 
Size:	177.7 KB 
ID:	35977

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Need to format columns with right alignment. By default, text aligns left and numbers align right
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    lccrews is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Location
    Los Angeles
    Posts
    194
    I'm not sure we're on the same page June. There are columns inserted into the sheet between the each of the values in Range("C1:S1"). Long after that, the second crosstab query is exported. I need to match up the second query with the first query. To do that, I think that I need to somehow search through Range("C35:I35") for the values that reside in the first row. Then, when a value is found, move that range over to the right column. I'm not sure how to do that.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Okay, think I get it. Those are two images. The first shows incorrect alignment for the yellow highlighted data and the second is correct.

    The first export shows two columns under each whatever-that-code-represents and the second export has only 1 and does not have all same headers.

    Yes, I expect will involve a bunch of code. Afraid you are on your own. Can use Excel macro recorder to help get some of the code structure and syntax but adapting to run in the Access procedure won't be quick nor easy.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    lccrews is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Location
    Los Angeles
    Posts
    194
    Oy. That scares me. Would it be easier to set up 10 functions...
    For example:
    Set rng = wks.Range("C35:L45")
    Set v = wks.Cells("C1")
    With rng
    If Cel.value = v then
    *copy that cell and 5 cells beneath it, paste them to wks.Range("C46:C51")* - This part idk how to do.
    End If
    End With

    Then do this again for D1, then again for E1, etc.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    You can certainly try.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 04-13-2017, 02:49 PM
  2. Lining up controls and main form and subform.
    By Lou_Reed in forum Access
    Replies: 3
    Last Post: 10-01-2015, 01:30 PM
  3. Lining things up
    By Lou_Reed in forum Access
    Replies: 19
    Last Post: 08-20-2015, 11:33 AM
  4. Lining up Tab Controls on a Form
    By RayMilhon in forum Forms
    Replies: 7
    Last Post: 10-09-2014, 06:55 AM
  5. Lining a pop form to parent form
    By IdleJack in forum Access
    Replies: 1
    Last Post: 09-19-2011, 12:19 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums