Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6871677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:50:06+00:00 2026-05-27T03:50:06+00:00

I want to create a Sub that basically allows me to target an Excel

  • 0

I want to create a Sub that basically allows me to target an Excel table with a specific name and then insert a new row at the bottom and add data to that row at the same time. Then exit the sub. And if the table only has one row with no data in it, add the data to that row and then exit the sub.

How can I do this?

I was thinking something like this, in pseudo code:

Public Sub addDataToTable(ByVal strTableName as string, ByVal strData as string, ByVal col as integer)

ActiveSheet.Table(strTableName).Select
If strTableName.Rows.Count = 1 Then
    strTableName(row, col).Value = strData
Else
    strTable(lastRow, col).Value = strData
End if

End Sub

This is probably not valid as code at all, but it should explain what I’m after at least!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:50:06+00:00Added an answer on May 27, 2026 at 3:50 am

    Is this what you are looking for?

    Option Explicit
    
    Public Sub addDataToTable(ByVal strTableName As String, ByVal strData As String, ByVal col As Integer)
        Dim lLastRow As Long
        Dim iHeader As Integer
    
        With ActiveSheet.ListObjects(strTableName)
            'find the last row of the list
            lLastRow = ActiveSheet.ListObjects(strTableName).ListRows.Count
            'shift from an extra row if list has header
            If .Sort.Header = xlYes Then
                iHeader = 1
            Else
                iHeader = 0
            End If
        End With
        'add the data a row after the end of the list
        ActiveSheet.Cells(lLastRow + 1 + iHeader, col).Value = strData
    End Sub
    

    It handles both cases whether you have header or not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want create a excel with Apache POI in java and I must insert
I want to create sub-domains using PHP on the fly. Suppose a user registers
i want to create sub menu for a BB application when i click on
I want to create a transaction, writing some data in a sub-transaction, reading the
I want to create a function that performs a function passed by parameter on
I want to create a simple http proxy server that does some very basic
I want to create a set of classes that share a lot of common
Suppose I have an immutable NSArray and want to create several sub-arrays. I could
I need to create a sub-function that will return me all the adjacent node,
Basically i want to create XMLDesigner kind of thing in Flex, using which user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.