Results 1 to 2 of 2

Help! Create Table with variable rows in VBA

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

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