+ Reply to Thread
Results 1 to 2 of 2

Help! Create Table with variable rows in VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    04-26-2017
    Location
    Denmark
    MS-Off Ver
    2007
    Posts
    3

    Help! Create Table with variable rows in VBA

    Hi All
    I need some help to figure out how I can create a Tabel I VBA.
    I need the table to contain the number of rows that the user is typing in an InputBox. Can anyone help me?
    My code i so far:

    Sub NumberOfStudents()
    'Denn Macro afspiller den indledning som der skal være for at få informationer til de nye pladser.
    Dim Number As Integer
    Dim Klasse As String
    Dim Message As String
    
    Klasse = InputBox("Angiv venligst klassens nummer")
    Number = InputBox("Angiv venligst antal af elever i deres klasse")
    If Number <= 2 Then
    MsgBox ("Der er vist ingen grund til at lave nye pladser")
    Else
    MsgBox ("I " & Klasse & " er der " & Number & " elever")
    End If
    'Macroen skal laves så programmet lukker, hvis at der ikke udfyldes mere en 2 elever.
    
    MsgBox ("Du bedesvenligst udfylde navnene på dine elever i tabellen der vises når du klikker OK")
    
    End Sub
    
    
    
    Sub ActivateInsertRow()
    
    Dim wrksht As Worksheet
    Dim objList As ListObject
    Dim objListRng As Range
    
    objListRng = Number
    
    
    Set wrksht = ActiveWorkbook.Worksheets(1)
    Set objList = wrksht.ListObjects(1)
    Set objListRng = objList.InsertRowRange
    
    If objListRng Is Nothing Then
    ActivateInsertRow = False
    Else
    objListRng.Activate
    ActivateInsertRow = True
    End If
    
    End Sub
    Thanks!
    Last edited by OlliHoup; 04-26-2017 at 05:47 PM.

  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: Help! Create Table with variable rows in VBA

    Hi and welcome to the forum
    Unfortunately your post does not comply with Rule 3 of our Forum
    RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    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.

+ 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. Replies: 2
    Last Post: 04-16-2013, 06:17 AM
  2. [SOLVED] Macro to create a pivot with variable rows.
    By markDuffy in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-22-2013, 10:44 AM
  3. Create Table using Variable Column and Rows
    By Craxuan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-09-2011, 10:16 AM
  4. Using a Variable in vba SQL to create a table
    By Dave31 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-30-2008, 09:46 AM
  5. Create a variable rate bond table
    By mkmed in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-29-2007, 01:31 PM
  6. Variable number of rows to create graph
    By Smthian in forum Excel General
    Replies: 1
    Last Post: 03-02-2005, 02:17 PM
  7. How do I create a one variable data table?
    By Prelll91 in forum Excel General
    Replies: 1
    Last Post: 02-27-2005, 04:06 PM
  8. Create a table with different values for the same variable
    By Mitchs_35 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-07-2005, 06:26 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