• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

New row in excel with predefined data

aka2022

New Member
Hi all,
Is there a way to add a new row with same data everytime I encounter Row ID 5 in the 3rd column per the below screenshot?
I want to add a row with Row ID 6 and Name NewCity.
I have a similar data but with about 100 countries, more columns and have to add particular set of data for all the countries. I am very new to this so that's why asking for a solution for this one if any one can help.
Thank you!
 

Attachments

  • Capture2.PNG
    Capture2.PNG
    12.2 KB · Views: 10
Hi, is there a way to respect first forum rules ?​
As this is a wild cross-posting, you must edit your initial post and add a link for each other forum​
where you have created the same thread and do the same on every other forum thread …​
 
Cross-posted at
 
Last edited by a moderator:
Thanks for the links : according to your initial post it is already solved on another forum …​
 

aka2022

  • Cross-Posting. Generally, it is considered poor practice to cross post. That is to post the same question on several forums in the hope of getting a response quicker.
  • If you do cross-post, please put that in your post.
  • Also if you have cross-posted and get an Solution elsewhere, have the courtesy of posting the Solution here so other readers can learn from the answer also, as well as stopping people wasting their time on your answered question.
 
my apologies, i didn't know about the cross-post. Anyways, I will keep that in mind.

I found a solution and here it is

>>> use code - tags <<<
Code:
Option Explicit


Sub AddNumber15()
    Dim r As Long, rBottom As Long
   
    Application.ScreenUpdating = False
   
    With ActiveSheet
        rBottom = .Cells(.Rows.Count, 32).End(xlUp).Row
   
        'best to go bottoms up
        For r = rBottom To 2 Step -1
            If .Rows(r).Cells(32).Value = 14 Then
                .Rows(r + 1).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
                .Rows(r + 1).Cells(32).Value = 15
                .Rows(r + 1).Cells(36).Value = "New City"
            End If
        Next r
    End With
   
    Application.ScreenUpdating = True


End Sub
 
Last edited by a moderator:

aka2022

You wrote ... i didn't know about the cross-post. ...
How did You open You the 1st time Chandoo.org -site?
Isn't there the 1st forum ... New Users - Please Start Here?
Screenshot 2023-09-01 at 18.17.11.png
... and something same, You could find from every site.
 
Back
Top