Skip to main content

Conas luach meaitseála a bhreathnú agus a thabhairt ar ais le trácht cille?

Nuair a chuireann tú feidhm Vlookup i bhfeidhm chun an luach meaitseála a thabhairt ar ais, ní bhainfidh sé an luach ach gan an fhormáidiú, mar shampla dath líonta, cló nó trácht srl. Ach, uaireanta, b’fhéidir go mbeidh ort an luach comhoiriúnaithe lena n-áirítear trácht a aischur agus a thabhairt ar ais freisin chun an toradh scáileáin seo a leanas a fháil. Conas a d’fhéadfá an post seo a réiteach in Excel?

Luach meaitseála Vlookup agus faigh ar ais le trácht cille trí chód VBA a úsáid


Luach meaitseála Vlookup agus faigh ar ais le trácht cille trí chód VBA a úsáid

D’fhéadfadh go gcabhróidh an cód VBA thíos leat luach comhoiriúnaithe a bhreathnú agus a chur ar ais lena thrácht, déan mar a leanas:

1. Coinnigh síos an ALT + F11 eochracha a oscailt Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

2. Cliceáil Ionsáigh > Modúil, ansin cóipeáil agus greamaigh an cód seo a leanas sa Modúil Fuinneog.

Cód VBA: Luach meaitseála Vlookup agus faigh ar ais le trácht cille:

Function VlookupComment(LookVal As Variant, FTable As Range, FColumn As Long, FType As Long) As Variant
'Updateby Extendoffice
    Application.Volatile
    Dim xRet As Variant 'could be an error
    Dim xCell As Range
    xRet = Application.Match(LookVal, FTable.Columns(1), FType)
    If IsError(xRet) Then
        VlookupComment = "Not Found"
    Else
        Set xCell = FTable.Columns(FColumn).Cells(1)(xRet)
        VlookupComment = xCell.Value
        With Application.Caller
            If Not .Comment Is Nothing Then
                .Comment.Delete
            End If
            If Not xCell.Comment Is Nothing Then
                .AddComment xCell.Comment.Text
            End If
        End With
    End If
End Function

3. Agus ansin an cód a shábháil agus an fhuinneog cód a dhúnadh, iontráil an fhoirmle seo: = vlookupcomment (H2, A2: C10,3, BRÉAGACH) isteach i gcill bhán chun an toradh a aimsiú, agus brúigh Iontráil eochair, tugtar an luach comhoiriúnaithe chomh maith leis an trácht ar ais ag an am céanna, féach an pictiúr:

nótaí: San fhoirmle thuas, H2 an luach cuardaigh is mian leat a luach comhfhreagrach a thabhairt ar ais, A2: C10 an tábla sonraí a theastaíonn uait a úsáid, an uimhir 3 is í uimhir an cholúin ina bhfuil an luach comhoiriúnaithe a theastaíonn uait a thabhairt ar ais.

Uirlisí Táirgiúlachta Oifige is Fearr

🤖 Kutools AI Aide: anailís sonraí a réabhlóidiú bunaithe ar: Forghníomhú Chliste   |  Gin Cód  |  Cruthaigh Foirmlí Saincheaptha  |  Anailís a dhéanamh ar Sonraí agus Cairteacha a Ghin  |  Feidhmeanna Kutools a agairt...
Gnéithe Coitianta: Faigh, Aibhsigh nó Aithnigh Dúblaigh   |  Scrios Sraitheanna Bána   |  Comhcheangail Colúin nó Cealla gan Sonraí a Chailleadh   |   Babhta gan Foirmle ...
Cuardaigh Super: Ilchritéir VLookup    VLookup Illuachanna  |   VLookup Trasna Ilbhileoga   |   Amharc doiléir ....
Liosta anuas Casta: Go tapa Cruthaigh Liosta Anuas   |  Liosta anuas Cleithiúnach   |  Liosta Buail Isteach Ilroghnacha ....
Bainisteoir Colún: Cuir Líon Sonrach Colún leis  |  Colúin Bog  |  Scoránaigh Stádas Infheictheachta na gColún Ceilte  |  Déan comparáid idir Raonta & Colúin ...
Gnéithe Réadmhaoin: Fócas Eangaí   |  Amharc Dearaidh   |   Barra Mór na Foirmle    Leabhar Oibre & Bainisteoir Bileog   |  Leabharlann Acmhainní (Uaththéacs)   |  Piocálaí Dáta   |  Comhcheangail Bileoga Oibre   |  Criptigh/Díchriptigh Cealla    Seol Ríomhphost trí Liosta   |  Scagaire Super   |   Scagaire Speisialta (scagaire trom/iodálach/stailc tríd...) ...
Barr 15 Uirlisí12 Téacs uirlisí (Cuir Téacs, Bain Carachtair,...)   |   50 + Cairt cineálacha (Cairt Gantt,...)   |   40+ Praiticiúil Foirmlí (Ríomh aois bunaithe ar lá breithe,...)   |   19 Insertion uirlisí (Cuir isteach Cód QR, Ionsáigh Pictiúr ón gCosán,...)   |   12 Tiontú uirlisí (Uimhreacha le Focail, Comhshó Airgeadra,...)   |   7 Cumaisc & Scoilt uirlisí (Sraitheanna Comhcheangail Casta, Cealla Scoilt,...)   |   ... agus eile

Supercharge Do Scileanna Excel le Kutools le haghaidh Excel, agus Éifeachtúlacht Taithí Cosúil Ná Roimhe. Kutools le haghaidh Excel Tairiscintí Níos mó ná 300 Ardghnéithe chun Táirgiúlacht a Treisiú agus Sábháil Am.  Cliceáil anseo chun an ghné is mó a theastaíonn uait a fháil ...

Tuairisc


Tugann Tab Oifige comhéadan Tabbed chuig Office, agus Déan Do Obair i bhfad Níos Éasca

  • Cumasaigh eagarthóireacht agus léamh tabbed i Word, Excel, PowerPoint, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méadaíonn do tháirgiúlacht 50%, agus laghdaíonn sé na céadta cad a tharlaíonn nuair luch duit gach lá!
Comments (20)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
txs a lot. highly appreciated!
This comment was minimized by the moderator on the site
Hello this is a very good function, but it works for Notes, not Comments (this is how it is translated in my native language at least). Is there some way to change it from Notes to Comments? Also, is there a way to keep the cell format? (color of the original cell, etc).
This comment was minimized by the moderator on the site
i've had the same issue. i can only say that having tried via vba to copy comments and notes... only notes are being copied, not the comments (although the have the same meaning, but a different functionality)... Notes seem to be of a static nature, unlike comments where you can keep "posting" to adding new text...Probably that's the reason....
This comment was minimized by the moderator on the site
Hi, fana,
To extract the matched records with the comment in Office 365, please apply the below code:
Function VlookupComment(LookVal As Variant, FTable As Range, FColumn As Long, FType As Long) As Variant
'Updateby Extendoffice
    Application.Volatile
    Dim xRet As Variant 'could be an error
    Dim xCell As Range
    xRet = Application.Match(LookVal, FTable.Columns(1), FType)
    If IsError(xRet) Then
        VlookupComment = "Not Found"
    Else
        Set xCell = FTable.Columns(FColumn).Cells(1)(xRet)
        VlookupComment = xCell.Value
        With Application.Caller
            If Not .CommentThreaded Is Nothing Then
                .ClearComments
            End If
            If Not xCell.CommentThreaded Is Nothing Then
                .AddCommentThreaded xCell.CommentThreaded.Text
            End If
        End With
    End If
End Function


After pasting the code, apply this formula: =vlookupcomment(H2,A2:C10,3,FALSE) as well.

Please try, hope it can help you!
This comment was minimized by the moderator on the site
Not working for me. I get #NAME? error when i use this formula. Please help.
This comment was minimized by the moderator on the site
Hello, Sajjad,Did you put the VBA code of this article into your workbook? Please check it.Or which Excel version do you use?Thank you!
This comment was minimized by the moderator on the site
This is a wonderful. But when using this code I find the file crashes a lot on Excel 365. when removing auto save I found it’s a little better. But with multiple users in the file, the file will crash all the time. Does this code use a lot of memory or is it a compatibility issue? Thoughts? Thanks
This comment was minimized by the moderator on the site
Hi! I'm so glad I found this, the thing is, this actually works on notes, and not comments. is there a way to have work on comments and not notes? in notes i cannot tag my coworkers and i cannot reply either. thanks a lot!
This comment was minimized by the moderator on the site
i can do that at the first time. but after i try to use changing formula of multiple cells. It doesn't work now. after even i type vlookupcomment, the cell becomes blank.
This comment was minimized by the moderator on the site
My comment is too large for the default box size. Is there any way to increase the comment box size or possibly decrease the font size?
This comment was minimized by the moderator on the site
If anyone else needs this.


Function VlookupComment(LookVal As Variant, FTable As Range, FColumn As Long, FType As Long) As Variant

'Updateby Extendoffice

Application.Volatile

Dim xRet As Variant 'could be an error

Dim xCell As Range

xRet = Application.Match(LookVal, FTable.Columns(1), FType)

If IsError(xRet) Then

VlookupComment = "-"

Else

Set xCell = FTable.Columns(FColumn).Cells(1)(xRet)

VlookupComment = xCell.Value

With Application.Caller

If Not .Comment Is Nothing Then

.Comment.Delete

End If

If Not xCell.Comment Is Nothing Then

.AddComment xCell.Comment.Text

.Comment.Shape.ScaleWidth 2, msoFalse, msoScaleFromTopLeft

.Comment.Shape.ScaleHeight 2.5, msoFalse, msoScaleFromTopLeft

End If

End With

End If

End Function
This comment was minimized by the moderator on the site
I want only Comment as Cell Value using Vlookup...
This comment was minimized by the moderator on the site
Thanks, It's helpful & I have something to askIt returns with cell comment but the Image (Inserted using fill effects ) does not show
Please , help me out of this Issue
This comment was minimized by the moderator on the site
Shamim,
Sorry for that there is no direct code for solving your problem, if anyone has the solution, please comment here.
This comment was minimized by the moderator on the site
Frank
Hello,

In case of spreadsheet protected, when I open my workbook the cell return the error #VALUE!

How we can solve this problem?
This comment was minimized by the moderator on the site
Hello, Frank,
After inserting the code, you should save your workbook as Excel Macro-Enabled Workbook format, so that the code will not lose.
Please try! Thank you!
This comment was minimized by the moderator on the site
Can we use cell in column B (order column) as comment for cell in column C (name). exc, comment for Helen is 80.
thank you for your help.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations