+ Reply to Thread
Results 1 to 5 of 5

Adding line tot able & Writing to excel sheet through Array

  1. #1
    Registered User
    Join Date
    12-01-2016
    Location
    Québec
    MS-Off Ver
    MS Office 2010
    Posts
    5

    Adding line tot able & Writing to excel sheet through Array

    Hello everybody,

    I am working on some sort of excel ledger at work. When you initialize it, it grabs data from a text file, processes it and inserts it in a pre-made table. I'm having some issues with two subroutines in particular that are called during this whole process. They are the subroutines that add lines to the table (so were sure there are enough in the table to take the data we are going to feed it) and the one that takes the array I had prepared from the text file and writes it out in the table. Here they are:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    I have verified with countless Debug.Print calls and re-runs. The procedures are called, they run to the end, the array & the range have the exact same size, the array does contain data, the array is a Variant type, but somehow those two actions (adding lines and pasting the array) are never done. Everything else works just fine. I don't even get an error or anything like that, the lines are just ignored. Even worse, when I write a dummy subroutine to set up a dummy array and feed it to Populate_TC85, everything seems to work fine. I kind of am at my wits' end here.

    The only thing I could imagine (I'll test it out tomorrow) is that maybe it's because my array contains varied data types (strings, numbers, vbNullStrings...), while the dummy array I created to test only contained strings...?

    Does anybody have a stroke of genius of why that might be?

    Thanks a bunch in advance!

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Adding line tot able & Writing to excel sheet through Array

    Difficult to say without seeing the workbook.

    Just a thought, but why are you including the Header row in the count of rows to add?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Adding line tot able & Writing to excel sheet through Array

    Have you stepped through the code with F8 to see what's actually happening?
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    12-01-2016
    Location
    Québec
    MS-Off Ver
    MS Office 2010
    Posts
    5

    Re: Adding line tot able & Writing to excel sheet through Array

    Oh I didn't know the F8 thing, will definitely try that out tomorrow, see if I can find out more, thanks!

    About the header row thing in the count of rows: it's because the table doesn't start at line 1 of the sheet and RowPosition is the relative position in the table, not the absolute row on the sheet.

    I'll see if I can post a larger chunk of the code but I'm not super sure I'm allowed to share the whole workbook as it's a work thing. Besides I'm in the process of cleaning it up and there's a lot of confusing loose ends in various places (there shouldn't be in this part of the code however).

  5. #5
    Registered User
    Join Date
    12-01-2016
    Location
    Québec
    MS-Off Ver
    MS Office 2010
    Posts
    5

    Re: Adding line tot able & Writing to excel sheet through Array

    Sorry if double-posting in frowned upon here, just chiming in to say I've figured out my problem. Basically it -was- working but it was not adding rows & inserting the data on the sheet I was expecting it to. It was an easy fix once I figured that out.

    Thanks for the F8 trick, it's what really helped me find out the problem, I'll definitely remember this in the future!

+ 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. [SOLVED] bypass writing array to sheet to calculate count routine
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-21-2018, 11:07 AM
  2. writing an array with more than one row in vba excel...
    By siba in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-29-2012, 06:18 AM
  3. Difficulty adding a trend line to line graph in Excel 2007
    By jmatoske in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 11-28-2012, 02:59 PM
  4. Replies: 6
    Last Post: 11-26-2012, 05:17 AM
  5. writing formula in range on each sheet via array
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-20-2011, 12:59 PM
  6. Adding a line of data to more than one sheet automatically
    By lamoprizm in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-15-2009, 12:31 PM
  7. Writing Single Dimension Array to Active Sheet
    By Fid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-23-2005, 05: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