Jump to content
Forum Roportal

Recommended Posts

Am rezolvat-o cu problema mea in care vroiam cind selectez ceva sa imi apara o imagine iar cind selectez altceva sa dispara imaginea precedenta si sa apara o alta imagine.Dar , intotdeauna esxista un DAR, pentru a explica si celorlalti cum am facut, trebuie sa-mi explice urmatorul cod :

 

Private Sub Worksheet_Calculate()

Dim myCell As Range

Dim mySel As Range

 

Set mySel = Selection

 

With Application

.EnableEvents = False

.DisplayAlerts = False

.ScreenUpdating = False

 

On Error Resume Next

For Each myCell In Range("K14")

ActiveSheet.Shapes(myCell.Address & "Final").Delete

ActiveSheet.Shapes(myCell.Value).Select

Selection.Copy

myCell.Offset(0, 1).Select

ActiveSheet.Paste

Selection.Name = myCell.Address & "Final"

Selection.ShapeRange.ZOrder msoSendToBack

Next myCell

 

mySel.Select

 

.EnableEvents = True

.DisplayAlerts = True

.ScreenUpdating = True

End With

End Sub

 

Acest cod este scris in interiorul foi de lucru adica dai click dreapta pe denumirea foii si alegi View Code si se deschide o fereastra de VB de editare cod.

Ce inseamna sau ce vrea sa spuna acest cod daca se poate sa-l explicati linie cu linie ar fi mult mai bine sa-l inteleg si eu.

Multumesc anticipat.

Share this post


Link to post
Share on other sites

Private Sub Worksheet_Calculate()

Dim myCell As Range

Dim mySel As Range

 

Set mySel = Selection

 

With Application

.EnableEvents = False

.DisplayAlerts = False

.ScreenUpdating = False

 

On Error Resume Next daca apare o eroare treci la pasul urmator (o ignora)

For Each myCell In Range("K14") pentru fiecare celula din domeniul K14

ActiveSheet.Shapes(myCell.Address & "Final").Delete sterge desenul cu numele AdresaCeluleiCurente + Final

ActiveSheet.Shapes(myCell.Value).Select selecteaza desenul cu numele ValoareaCeluleiCurente

Selection.Copy copiaza desenul selectat la linia anterioara

myCell.Offset(0, 1).Select selecteaza celula aflata la 0 coloane si 1 randuri distanta de celula curenta (urmatoarea celula in jos)

ActiveSheet.Paste lipeste desenul copiat

Selection.Name = myCell.Address & "Final" redenumeste celula selectata cu numele AdresaCeluleiMele + Final

Selection.ShapeRange.ZOrder msoSendToBack pune desenul in fundal la celula selectata (scrisul sa fie deasupra desenului)

Next myCell treci la celula urmatoare din domeniu (nici n-o sa aiba unde, pentru ca domeniul contine o singura celula :baby: )

 

mySel.Select

 

.EnableEvents = True

.DisplayAlerts = True

.ScreenUpdating = True

End With

End Sub

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×