+ Reply to Thread
Results 1 to 2 of 2

Insert Text in Multiple Cells in Condition or Criteria

  1. #1
    Registered User
    Join Date
    08-20-2018
    Location
    Philippines
    MS-Off Ver
    2013
    Posts
    4

    Insert Text in Multiple Cells in Condition or Criteria

    I want to insert Text in Multiple Cells with the following Criteria using userform to input value

    Sub AddSaturdaySunday()
    ' get the last row
    Dim startRow As Long, lastRow As Long
    startRow = 14
    lastRow = Sheet1.Cells(Sheet1.Rows.Count, 1).End(xlUp).Row

    Dim i As Long, Mydate As String
    Dim sDate As String

    ' Go through the marks columns
    For i = startRow To lastRow
    Mydate = Sheet1.Range("B" & i).Value


    ' Check Mydate and classify accordingly then print Saturday and Sunday
    If Mydate = "11" Then
    sDate = "Saturday"


    ElseIf Mydate = "12" Then
    sDate = "Sunday"

    Else
    'For this part it must NOT REPLACE the value if the conditions above are not meet

    End If


    ' Write out the Saturday and Sunday column C
    Sheet1.Range("C" & i).Value = sDate
    Next

    End Sub

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166
    Hello francis.mata,

    Welcome to Excelforum. Be a part of large Excel community. Enjoy Learning.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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. Macro to combine text from multiple cells when one condition is met
    By dobracik in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-08-2017, 03:08 PM
  2. Replies: 2
    Last Post: 05-26-2015, 07:29 PM
  3. [SOLVED] Formula to break cells but also to insert different text if condition met
    By gokica in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-19-2014, 08:02 AM
  4. Replies: 1
    Last Post: 12-25-2012, 05:32 PM
  5. Replies: 1
    Last Post: 12-20-2012, 04:18 PM
  6. Excel Macro to insert two rows based on condition and copy and paste multiple cells
    By mannabhalo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-13-2012, 12:56 PM
  7. Macro to insert text into empty cells with a specified criteria
    By wrightie in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-04-2009, 12:18 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