+ Reply to Thread
Results 1 to 16 of 16

Assigning a variable and pasting variable to last unused column.

  1. #1
    Registered User
    Join Date
    11-19-2008
    Location
    Chicago
    Posts
    12

    Assigning a variable and pasting variable to last unused column.

    Hi all.
    Rather then waste another 4 hours trying to figure this out, ill just ask.

    I need to assign a variable to equal a Constant variable, then I need to find the last unused row on the worksheet, then paste that variable down the column (1-12200 or so rows). I also need to assign Strings for the first two Rows in the target column.

    Please Login or Register  to view this content.


    Sorry, dont have much VB experience.
    Last edited by VBA Noob; 11-19-2008 at 05:27 PM. Reason: Added code tags as per forum rules

  2. #2
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    re: Assigning a variable and pasting variable to last unused column

    That's not much code to start with. Please upload your sheet as we need to see how the data is distributed.

    Start by recording your steps and I think you should use the Edit -> GoTo -> Special for this.

    We'll make sensable code out of that.
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  3. #3
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    Insert a Module and paste:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    11-19-2008
    Location
    Chicago
    Posts
    12
    Quote Originally Posted by rwgrietveld View Post
    That's not much code to start with. Please upload your sheet as we need to see how the data is distributed.

    Start by recording your steps and I think you should use the Edit -> GoTo -> Special for this.

    We'll make sensable code out of that.
    My problem is I dont know exactly how to code the rest.. Prior to this I have numerous Calls to populate the sheet. This code has to occur after them. I need to count the used columns, and find the last unused one, then paste the String PressureFilterDrop and then the Units °C then the variable.
    Basically it'll look like this in Excel


    FilterFlow TransferMassFlow FilterPressureDrop
    m³/s g/s °C
    0.001545833 0.593156197 -99
    0.001546667 0.595364971 -99
    0.001546667 0.595364971 -99
    0.001546667 0.595364971 -99
    0.001546667 0.597172149 -99
    ect
    ect

    to End Rows
    Last edited by Ageia; 11-19-2008 at 05:55 PM.

  5. #5
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    Not sure what you want to paste. Pasting may not be the best route.

    If you attach an xls with a before an after example, it might be easier to help you.

  6. #6
    Registered User
    Join Date
    11-19-2008
    Location
    Chicago
    Posts
    12
    Quote Originally Posted by Kenneth Hobson View Post
    Not sure what you want to paste. Pasting may not be the best route.

    If you attach an xls with a before an after example, it might be easier to help you.
    would like to see something like this in the end.

    \1

  7. #7
    Registered User
    Join Date
    11-19-2008
    Location
    Chicago
    Posts
    12
    Quote Originally Posted by Kenneth Hobson View Post
    Not sure what you want to paste. Pasting may not be the best route.

    If you attach an xls with a before an after example, it might be easier to help you.
    I cant upload anything. The site is reporting database errors.

  8. #8
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    It is still not clear.

    If you have that data in another range, then a copy/paste is easy. Of course I still wouldn't know where you would want it pasted.

    e.g. Data in A1:E21. I am guessing you want the range in the image on some sheet pasted to say F22? That is one row down and one column over from the sheet's UsedRange.

  9. #9
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    Try posting to a shared site like 4shared.com, box.net or mediafire.com.

  10. #10
    Registered User
    Join Date
    11-19-2008
    Location
    Chicago
    Posts
    12
    Quote Originally Posted by Kenneth Hobson View Post
    Try posting to a shared site like 4shared.com, box.net or mediafire.com.

    Ahh thanks again for even more advice! I really appreciate it! At last, here's the file with a decent example.

    http://www.4shared.com/file/72341280...elExample.html

  11. #11
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    Insert a Module and paste this and play it.
    Please Login or Register  to view this content.
    Last edited by Kenneth Hobson; 11-20-2008 at 11:32 AM.

  12. #12
    Registered User
    Join Date
    11-19-2008
    Location
    Chicago
    Posts
    12
    Quote Originally Posted by Kenneth Hobson View Post
    Insert a Module and paste this and play it.
    Please Login or Register  to view this content.



    Ahh, that would work well, but.. I dont know where the Range is I need to paste. I need to count the Rows and Columns store them in strings and then paste this at the first unused column, until the endrow. Like a perfect box of data.

    Please Login or Register  to view this content.
    Last edited by Ageia; 11-20-2008 at 02:25 PM.

  13. #13
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    Paste what? Store row and columns counts as strings? I see no purpose in that.


    My code made your Before sheet look like your After sheet.

    Maybe this will help you see what you want.

    Please Login or Register  to view this content.
    Otherwise, maybe someone else can see what you want.
    Last edited by Kenneth Hobson; 11-20-2008 at 03:18 PM.

  14. #14
    Registered User
    Join Date
    11-19-2008
    Location
    Chicago
    Posts
    12
    please see the attached jpeg for a better idea.

    I need find the last used column and increment by one which would be C, so the column i need to write to is D.

    then I need to write my strings, Filterpressuredrop, and the units DegC.

    I then need to count the rows used by the rest of the data, which wlould be 19 rows and only write -99 from ("D3:D19")only. I basically need to figure out the Range of the rest of the Data in the sheet and just paste this at the end column to the end row so it looks similar.

    Reason for the counting is that the number of rows change quite frequently. This Data is coming from a system logging it @ 10Hz so its not perfect every time. The column names stay the same pretty much, but if I decide to add data channels later, i'd still like this to appear as the last column of data.
    Attached Images Attached Images
    Last edited by Ageia; 11-20-2008 at 03:25 PM.

  15. #15
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    Similar to what I've posted before using those methods:
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    11-19-2008
    Location
    Chicago
    Posts
    12
    Quote Originally Posted by Kenneth Hobson View Post
    Similar to what I've posted before using those methods:
    Please Login or Register  to view this content.
    Thats it exactly! Thanks so much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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