Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Comment in every 10 the row

Hi Can anybody help in making a VBA

I have column A and B and I need a comment "AUDIT"in column C at every
11 row of column C.

I have tried the below but does not work

Sub MyMacro()
Dim lngRow As Long
For lngRow = 11 To Cells(Rows.Count, "D").End(xlUp).Row Step 11
If Range("D" & lngRow).Comment Is Nothing Then
Range("D" & lngRow).AddComment "Audit"
End If
Next
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Comment in every 10 the row

Hin,

In what way doesn't it work because it looks fine to me but I would suggest
you qualify those ranges with a worksheet name

Sub MyMacro()
Dim lngRow As Long
With Sheets("Sheet2")
For lngRow = 11 To .Cells(Rows.Count, "D").End(xlUp).Row Step 11
If .Range("D" & lngRow).Comment Is Nothing Then
..Range("D" & lngRow).AddComment Text:="Audit"
End If
Next
End With
End Sub



--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Radhakant Panigrahi" wrote:

Hi Can anybody help in making a VBA

I have column A and B and I need a comment "AUDIT"in column C at every
11 row of column C.

I have tried the below but does not work

Sub MyMacro()
Dim lngRow As Long
For lngRow = 11 To Cells(Rows.Count, "D").End(xlUp).Row Step 11
If Range("D" & lngRow).Comment Is Nothing Then
Range("D" & lngRow).AddComment "Audit"
End If
Next
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Comment in every 10 the row

Hi Mike,

Thanks for your reply, the below VBA works only when there is data in column
"D" and it is not putting comment in the cell like any value. rather it is
putting comment like we use the option "inserting comment'.

Actually column "D" is blank and i need the Text "AUDIT" to be filled in the
cell of the 10th row like any other normal value that we put in cells.


regards,
rkp

"Mike H" wrote:

Hin,

In what way doesn't it work because it looks fine to me but I would suggest
you qualify those ranges with a worksheet name

Sub MyMacro()
Dim lngRow As Long
With Sheets("Sheet2")
For lngRow = 11 To .Cells(Rows.Count, "D").End(xlUp).Row Step 11
If .Range("D" & lngRow).Comment Is Nothing Then
.Range("D" & lngRow).AddComment Text:="Audit"
End If
Next
End With
End Sub



--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Radhakant Panigrahi" wrote:

Hi Can anybody help in making a VBA

I have column A and B and I need a comment "AUDIT"in column C at every
11 row of column C.

I have tried the below but does not work

Sub MyMacro()
Dim lngRow As Long
For lngRow = 11 To Cells(Rows.Count, "D").End(xlUp).Row Step 11
If Range("D" & lngRow).Comment Is Nothing Then
Range("D" & lngRow).AddComment "Audit"
End If
Next
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default Comment in every 10 the row

When I saw your post a few days ago and Jacob's reply, I wondered if you just
wanted the text AUDIT in the cell instead of a cell comment. I'm not sure if
you want something every 10th row or every 11th row because you have said it
both ways. If you want AUDIT in column D (which is otherwise empty) every
10th row, try this:

Enter AUDIT in D10. Select D1:D10. Find the fill handle at the lower right
corner of D10 (cursor changes to a small black plus sign). Holding the left
mouse button down, drag the fill handle down column D. The 9 blank cells and
the cell with AUDIT will be copied as you drag.

If you prefer a macro, here is a variation of the one already given you:

Sub MyMacro()
Dim lngRow As Long
For lngRow = 10 To Cells(Rows.Count, "A").End(xlUp).Row Step 10
Range("D" & lngRow).Value = "Audit"
Next
End Sub

Hope this helps,

Hutch

"Radhakant Panigrahi" wrote:

Hi Mike,

Thanks for your reply, the below VBA works only when there is data in column
"D" and it is not putting comment in the cell like any value. rather it is
putting comment like we use the option "inserting comment'.

Actually column "D" is blank and i need the Text "AUDIT" to be filled in the
cell of the 10th row like any other normal value that we put in cells.


regards,
rkp

"Mike H" wrote:

Hin,

In what way doesn't it work because it looks fine to me but I would suggest
you qualify those ranges with a worksheet name

Sub MyMacro()
Dim lngRow As Long
With Sheets("Sheet2")
For lngRow = 11 To .Cells(Rows.Count, "D").End(xlUp).Row Step 11
If .Range("D" & lngRow).Comment Is Nothing Then
.Range("D" & lngRow).AddComment Text:="Audit"
End If
Next
End With
End Sub



--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Radhakant Panigrahi" wrote:

Hi Can anybody help in making a VBA

I have column A and B and I need a comment "AUDIT"in column C at every
11 row of column C.

I have tried the below but does not work

Sub MyMacro()
Dim lngRow As Long
For lngRow = 11 To Cells(Rows.Count, "D").End(xlUp).Row Step 11
If Range("D" & lngRow).Comment Is Nothing Then
Range("D" & lngRow).AddComment "Audit"
End If
Next
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default Comment in every 10 the row

On May 11, 5:27*pm, Radhakant Panigrahi wrote:
Hi Can anybody help in making a VBA

I have column A and B and I need a comment "AUDIT"in column C at every
11 row of column C.

I have tried the below but does not work

Sub MyMacro()
Dim lngRow As Long
For lngRow = 11 To Cells(Rows.Count, "D").End(xlUp).Row Step 11
If Range("D" & lngRow).Comment Is Nothing Then
Range("D" & lngRow).AddComment "Audit"
End If
Next
End Sub



Sub MyMacro()

Dim lngRow As Long

For lngRow = 11 To Cells(Rows.Count, "D").End(xlUp).Row Step 10

If Range("D" & lngRow).Comment Is Nothing Then Range("D" &
lngRow).AddComment "Audit"

Next lngRow

End Sub

This will work.

are you sure that the column D contains values.Because if Column D is
not filled in then Cells(Rows.Count, "D").End(xlUp).Row will be zero





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Show Excel comment on mouseover but not the comment indicator [email protected] Excel Programming 6 June 30th 15 02:30 AM
copy comment content to cell content as data not as comment Lilach Excel Discussion (Misc queries) 2 June 21st 07 12:28 PM
How do I remove the red corner in excel comment and keep comment? skeptic007 Excel Programming 2 March 29th 07 02:54 PM
How can I edit a comment w/o first having to select Show Comment Mary Ann Excel Discussion (Misc queries) 1 August 26th 05 12:34 AM
a comment plugin & copy paste directly from excel to comment ? fr. RFM Excel Worksheet Functions 0 December 1st 04 11:29 PM


All times are GMT +1. The time now is 10:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"