Display text in column

adamsm

Active Member
Joined
Apr 20, 2010
Messages
444
Hi anyone,

How could I make the following code to display the text in the code on column "F" below the last data row of column "C"; when the user changes the value in cell "J10"
Code:
Dim m As Long
    If Not Range("J10") = "" Then
    With Worksheets("MySheet")
        m = .Cells(.Rows.Count, 1).End(xlUp).Row
        If Not .Cells(m, 7) = "Welcome" Then
            .Cells(m + 1, 7) = "Welcome"
            .Cells(m + 1, 7).Font.Bold = True
            End If
    End With
End If

Any help on this would be kindly appreciated.

Thanks in advance.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
In the worksheet module enter this code and try
Code:
[/FONT]
[FONT=Courier New]Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("J10")) Is Nothing Then
 'Do your activity here....[/FONT]
[FONT=Courier New][/FONT] 
[FONT=Courier New] 

End If
End Sub
 
Upvote 0
Thanks for the reply. But the code still does not place the text below the last data row of column C, in column F.

How could I achieve this?
 
Upvote 0
From your worksheet press/hit Alt + F11 >> hit Ctrl + R >> you'll see your sheet name on the left handside, right click on it then click on view code >>
paste this code there in the blank white space....

Code:
[/FONT]
[FONT=Courier New]Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("J10")) Is Nothing Then
 Application.EnableEvents = False
 Range("C" & Rows.Count).End(xlUp).Offset(1, 0).Value = Range("J10").Value
 Application.EnableEvents = True
End If
End Sub

Then try changing values in J10 of the sheet....
 
Upvote 0
Thanks for the reply. Your code is placing the value that is on cell J10 below the last data row of column C in Column C.


What I want is to place the text "welcome" below the last data row of column C in column F.

I hope I've made my question clear.

Any help would be kindly appreciated.

Thanks in advance.
 
Upvote 0
not tested...
Code:
[/FONT]
[FONT=Courier New]Private Sub Worksheet_Change(ByVal Target As Range)[/FONT]
[FONT=Courier New]If Not Intersect(Target, Range("J10")) Is Nothing Then[/FONT]
[FONT=Courier New]Application.EnableEvents = False[/FONT]
[FONT=Courier New]Dim m As Long
    If Not Range("J10") = "" Then
    With Worksheets("MySheet")
        m = .Cells(.Rows.Count, 1).End(xlUp).Row
        If Not .Cells(m, 7) = "Welcome" Then
            .Cells(m + 1, 7) = "Welcome"
            .Cells(m + 1, 7).Font.Bold = True
            End If
    End With
End If[/FONT]
[FONT=Courier New]Application.EnableEvents = True[/FONT]
[FONT=Courier New]End If[/FONT]
[FONT=Courier New]End Sub[/FONT]
[FONT=Courier New]
 
Upvote 0
This is the same code that I've posted at the beginning of the post which does insert the text "welcome" in column 7 in reference to the last row in column 1. I want to insert the text "welcome" in column 7 in reference to the last data row is column 3 not column 1.

I hope I've made my question clear.

Any help would be kindly appreciated.
 
Upvote 0
The following modification worked for me. Thanks for the help.
Code:
[FONT=Courier New]Private Sub Worksheet_Change(ByVal Target As Range)[/FONT]
[FONT=Courier New]If Not Intersect(Target, Range("J10")) Is Nothing Then[/FONT]
[FONT=Courier New]Application.EnableEvents = False[/FONT]
[FONT=Courier New]Dim m As Long
    If Not Range("J10") = "" Then
    With Worksheets("MySheet")
        m = .Cells(.Rows.Count, 3).End(xlUp).Row
        If Not .Cells(m, 7) = "Welcome" Then
            .Cells(m + 1, 7) = "Welcome"
            .Cells(m + 1, 7).Font.Bold = True
            End If
    End With
End If[/FONT]
[FONT=Courier New]Application.EnableEvents = True[/FONT]
[FONT=Courier New]End If[/FONT]
[FONT=Courier New]End Sub[/FONT]
 
Upvote 0
I just tried this code....and it looking at col C it places Welcome in Col G, corresponding to col C adding 1 whcih is row
If you want it to be in same row then remove m +1 and make it just m,7

I have no idea what you're trying to do...
Code:
[/FONT]
[FONT=Courier New]Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("J10")) Is Nothing Then
Application.EnableEvents = False
Dim m As Long
    If Not Range("J10") = "" Then
    With Worksheets("Sheet1")
        m = .Cells(.Rows.Count, 3).End(xlUp).Row
        If Not .Cells(m, 7) = "Welcome" Then
            .Cells(m + 1, 7) = "Welcome"
            .Cells(m + 1, 7).Font.Bold = True
            End If
    End With
End If
Application.EnableEvents = True
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,839
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top