+ Reply to Thread
Results 1 to 16 of 16

Assigning a variable and pasting variable to last unused column.

Hybrid View

  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.

    Dim FilterPressureDrop as String
    Dim °C as String 
    Dim Cons as Double
    'Constant of FilterPressureDrop
    Cons = -99 
    'Write Data to last used column on sheet1 after all calls have been done. 
    Sheets("Sheet1").Select
    Columns("A:A")


    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:
    Option Explicit
    Const x = 99
     
    Sub FillA()
      Sheet1.Range("A1", Cells(Sheet1.UsedRange.Rows.Count, "A")).Value = x
    End Sub

  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
    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.

  8. #8
    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.

+ 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