+ Reply to Thread
Results 1 to 5 of 5

Autofill a cell with VBA

  1. #1
    Forum Contributor
    Join Date
    02-20-2022
    Location
    Indonesia
    MS-Off Ver
    Excel 2016
    Posts
    118

    Talking Autofill a cell with VBA

    Hi,

    I have a new worksheet from my previous macro that create a datasheet, but I want to add a text to the data if the value in the other cell bigger than 0.
    Is there any solution to my problem

    I already attach the sample.

    Thanks,
    Attached Files Attached Files

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,655

    Re: Autofill a cell with VBA

    May be:

    PHP Code: 
    Sub add()
    Dim cell As Range
    For Each cell In Range("E2:E" Cells(Rows.Count"E").End(xlUp).Row)
        If 
    IsNumeric(cell) And cell.Value 0 Then cell.Offset(, 1).Value "'0002"
    Next
    End Sub 
    Quang PT

  3. #3
    Forum Contributor
    Join Date
    02-20-2022
    Location
    Indonesia
    MS-Off Ver
    Excel 2016
    Posts
    118

    Re: Autofill a cell with VBA

    Quote Originally Posted by bebo021999 View Post
    May be:

    PHP Code: 
    Sub add()
    Dim cell As Range
    For Each cell In Range("E2:E" Cells(Rows.Count"E").End(xlUp).Row)
        If 
    IsNumeric(cell) And cell.Value 0 Then cell.Offset(, 1).Value "'0002"
    Next
    End Sub 
    What if I want to write "CAVL" as a header?

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,655

    Re: Autofill a cell with VBA

    Quote Originally Posted by Sultan1994 View Post
    What if I want to write "CAVL" as a header?
    Is it cell F1?

    PHP Code: 
    '.....
    Range("F1").value = "CAVL"
    For Each ... 

  5. #5
    Forum Contributor
    Join Date
    02-20-2022
    Location
    Indonesia
    MS-Off Ver
    Excel 2016
    Posts
    118

    Re: Autofill a cell with VBA

    Attachment 817617

    Works great.

    Thanks Mr. bebo, I Appreciate it.

+ 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. [SOLVED] How to include prefix for Series Autofill and automatically autofill next blank row?
    By soojungchoe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-09-2021, 07:49 PM
  2. Autofill base on Active Cell and Autofill by row count of another sheet
    By enyak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-19-2014, 10:06 PM
  3. [SOLVED] Autofill cell underneath but only if adjacent cell in next column contains data
    By picton2000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-01-2013, 07:36 AM
  4. [SOLVED] Autofill cell in a userform based on a previously filled in cell.
    By streamofmight in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-24-2012, 01:03 AM
  5. Macro for Autofill removes header info when there is no data to autofill
    By esturan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-06-2012, 01:42 PM
  6. Replies: 1
    Last Post: 06-17-2005, 04:05 PM
  7. Replies: 0
    Last Post: 03-02-2005, 12:06 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