Skip to main content

Conas cill a chliceáil faoi dhó agus 1 a chur leis an luach cille sin in Excel?

Taispeánfaidh an t-alt seo duit modh chun 1 a chur le luach cille go huathoibríoch agus é a chliceáil faoi dhó in Excel.

Cliceáil faoi dhó ar chillín agus cuir 1 le cód VBA


Cliceáil faoi dhó ar chillín agus cuir 1 le cód VBA

Is féidir leis an gcód VBA seo a leanas cabhrú leat 1 a chur le luach cille tar éis cliceáil faoi dhó. Déan mar a leanas le do thoil.

1. Cliceáil ar dheis ar an táb bileog a bhfuil na luachanna cille is gá duit a chur leis 1 le cliceáil faoi dhó. Ansin cliceáil Féach an cód ón roghchlár cliceáil ar dheis.

2. Sa popping suas Microsoft Visual Basic d’Fheidhmchláir an cód VBA thíos a fhuinneog, a chóipeáil agus a ghreamú isteach i bhfuinneog an Chóid.

Cód VBA: Cuir 1 le luach cille le cliceáil dúbailte

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    On Error Resume Next
    If Not Intersect(Target, Range("A1")) Is Nothing Then
      Range("A1").Value = Range("A1").Value + 1
      Cancel = True
    End If
End Sub

nótaí: Sa chód, is é A1 an chill a gcuirfidh tú uimhir 1 leis le cliceáil dúbailte.

3. Brúigh an Eile + Q eochracha ag an am céanna chun an fhuinneog Microsoft Visual Basic for Applications a dhúnadh.

Anois, trí chliceáil faoi dhó ar chill A1 cuirfidh sé 1 leis an luach atá ann mar atá thíos an pictiúr a thaispeántar.


Earraí gaolmhara:

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 (17)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
how can i answer by YES or NO by adding check mark?
This comment was minimized by the moderator on the site
What code would I you if I want to add 1 to multiple cells lets say E5:E15 but then add .5 or a different number to another group of cells like G5:515?
This comment was minimized by the moderator on the site
I cannot get this to work in multiple cells
Tried using, but it did not work


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
On Error Resume Next
If Not Intersect(Target, Range("B2:L14")) Is Nothing Then
Range("B2:L14").Value = Range("B2:L14").Value + 1
Cancel = True
End If
End Sub
This comment was minimized by the moderator on the site
Hi Stella,
Please apply the below VBA to solve the problem.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

On Error Resume Next

If Not Intersect(Target, Range("B2:L14")) Is Nothing Then

Target.Value = Target.Value + 1

Cancel = True

End If

End Sub
This comment was minimized by the moderator on the site
If you want to increment any cell in a workbook cell by double clicking on that cell but only that cell, this code works:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
On Error Resume Next
If Not Intersect(Target, Range(ActiveCell.Address)) Is Nothing Then
ActiveCell.Value = ActiveCell.Value + 1
Cancel = True
End If
End Sub
This comment was minimized by the moderator on the site
Dear Bill,
Thank you for sharing.
This comment was minimized by the moderator on the site
Thank You! that helped me a lot!
This comment was minimized by the moderator on the site
This is great! How do I do this for multiple cells? I type in "A1,A2" instead "A1", it makes both cells equal and adds 1 to both cells simultaneously. I'd like the cells to act independently.
This comment was minimized by the moderator on the site
Sorry I didn’t get your point.
This comment was minimized by the moderator on the site
Hello - agree with Steve this is great. I think what he would like (and me too) is to be able to add to the value of multiple different cells in the same tab by double clicking on them. He has amended the VBA formula so it says "A1,A2" instead of just "A1" however double clicking on "A1" adds 1 to both cells. Is it possible to change the formula so that multiple cells are included with the value of each only being increased when you click on it directly?
This comment was minimized by the moderator on the site
maybe by making a table with a range name. and updating the formula to include that?
This comment was minimized by the moderator on the site
Basically, with the code above, if you double clicked on A1, it would add 1 to A1. If I changed A1 to A1:A2 in the Target Range, then if I double clicked on A1 or A2, it would add 1 to A1. What I wanted was to add 1 to A1 only if I double clicked on A1, and add 1 to A2 only if I double clicked on A2. I also did not want to add 1 to both cells.

I think I have found what I was looking for:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("D5:BC56")) Is Nothing Then
Cancel = True
Range(Target.Address).Value = Val(Range(Target.Address).Value) + 1
End If
End Sub
This comment was minimized by the moderator on the site
This code does not seem to work for me. Don't I have to specify which is the Target.Adress ?
This comment was minimized by the moderator on the site
Dear Steve,
I got your point finally, and thank you for sharing.
This comment was minimized by the moderator on the site
Can we add a two digit number to the end of the date? for example i need to double click and add the current date and the next two digit number (20171030-01 then the next cell will show 20171030-02 upon double click)
This comment was minimized by the moderator on the site
Dear Matt,
The code only supports the number format cell. It can't work as your data 20171030-01 is text format. Sorry about that.
This comment was minimized by the moderator on the site
Dear Matt,
The code only supports the number format cell. It can work as your data 20171030-01 is a text format. Sorry about that.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations