+ Reply to Thread
Results 1 to 5 of 5

Posting Text to cell using VBA

  1. #1
    Registered User
    Join Date
    08-04-2016
    Location
    Austin, Texas
    MS-Off Ver
    2010
    Posts
    3

    Posting Text to cell using VBA

    Hello,

    I am trying to use VBA to insert text into a cell but I keep getting an error. I used

    Worksheets("Austin Site Tracker").Range("A" & index).Value = CatalogRange.Cells(catalog, 1).Value

    then to just simplify things, I just used

    Worksheets("Austin Site Tracker").Range("A21").Value = "Blah"

    and it is still giving me a #VALUE! error.

    Please help.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Posting Text to cell using VBA

    Hello,

    do you see the #VALUE! in cell A21? That's a bit hard to believe because that error comes from a formula.

    Please provide a bit more context, a screenshot, a sample file.

    cheers, teylyn

  3. #3
    Registered User
    Join Date
    08-04-2016
    Location
    Austin, Texas
    MS-Off Ver
    2010
    Posts
    3

    Re: Posting Text to cell using VBA

    I am using this function into cell F2 and i am seeing the #VALUE in F2

    Function Catalogcount(CatalogRange As Range, RangetoCheck As Range)
    Dim catalog As Integer
    Dim counter As Integer
    Dim index As Integer
    Dim text As String

    Application.Volatile

    counter = 0
    index = 21
    Worksheets("Austin Site Tracker").Range("A21:A40").Clear
    For catalog = 1 To RangetoCheck.count
    If WorksheetFunction.CountIf(CatalogRange, CatalogRange.Cells(catalog, 1)) <> 1 Then ' if catalog number is not unique, then check nonolist

    If WorksheetFunction.CountIf(Worksheets("Austin Site Tracker").Range("A21:A40"), CatalogRange.Cells(catalog, 1)) > 0 Then ' if catalog number is present, then skip this one
    ' skipping
    Else ' else add it to nonolist and run main sub
    Worksheets("Austin Site Tracker").Range("A" & index).Value = CatalogRange.Cells(catalog, 1).Value
    index = index + 1
    '
    If RangetoCheck.Cells(catalog, 1).Interior.Color <> 16777215 Then ' the cell had color so increment counter
    counter = counter + 1
    End If
    '
    End If
    Else ' else since it is unique, run main sub
    '
    If RangetoCheck.Cells(catalog, 1).Interior.Color <> 16777215 Then ' the cell had color so increment counter
    counter = counter + 1
    End If
    '
    End If
    Next catalog
    Worksheets("Austin Site Tracker").Range("A21:A40").Clear 'clean up
    Catalogcount = counter

    End Function

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Posting Text to cell using VBA

    A function cannot change ranges in the worksheet. It can only return a value to the cell where it is entered.

  5. #5
    Registered User
    Join Date
    08-04-2016
    Location
    Austin, Texas
    MS-Off Ver
    2010
    Posts
    3

    Re: Posting Text to cell using VBA

    i see. Thank you. i think I will just create an array and use that within the function.

+ 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. VBA code needed: Posting three most appearing text string in a culomn
    By ehmail84 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-20-2014, 05:52 AM
  2. Replies: 0
    Last Post: 02-24-2014, 08:49 PM
  3. Replies: 2
    Last Post: 02-23-2014, 06:10 PM
  4. Posting data to cell
    By bstubbs in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-09-2009, 10:03 AM
  5. Replies: 4
    Last Post: 03-23-2008, 06:27 PM
  6. Posting cell calues on a web page?
    By Brad1971 in forum Excel General
    Replies: 0
    Last Post: 08-06-2007, 05:22 AM
  7. [SOLVED] the owner of posting should be able to delete the posting
    By Mahendra in forum Excel General
    Replies: 7
    Last Post: 08-08-2005, 03:05 PM

Tags for this Thread

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