Aiuto selezione celle

akkarin

New Member
Joined
May 21, 2014
Messages
5
Ciao a tutti, sono nuovo del forum e anche se so l'inglese piuttosto bene preferisco chiedere in italiano.
Ho 26 anni e ho iniziato da poco a prendere in mano VBA per cercare di risolvere alcuni problemi contabili in azienda.

questo è il mio problema:

ho bisogno di selezionare tutte le celle che si trovano alla sinistra della cella attiva (ma sulla stessa riga, e cella attiva compresa). Supponendo che la cella attiva sia F21 ho bisogno di selezionare un Range che va da A21 a F21. La selezione deve andare bene per qualsiasi cella attiva del foglio di lavoro.

E' tutto il giorno che lavoro su questo progetto e sono talmente stanco che spero di aver scritto bene la richiesta.
 
<font face= "Courier New", Monospace><SPAN style="color:#00007F">Sub</SPAN> DemoHowEndWorks()<br><br>    <SPAN style="color:#00007F">Dim</SPAN> celColK     <SPAN style="color:#00007F">As</SPAN> Excel.Range, _<br>        celEndLeft  <SPAN style="color:#00007F">As</SPAN> Excel.Range, _<br>        rngColK     <SPAN style="color:#00007F">As</SPAN> Excel.Range, _<br>        rngDemo     <SPAN style="color:#00007F">As</SPAN> Excel.Range, _<br>        rngEndLeft  <SPAN style="color:#00007F">As</SPAN> Excel.Range, _<br>        wbNew       <SPAN style="color:#00007F">As</SPAN> Excel.Workbook, _<br>        wsNew       <SPAN style="color:#00007F">As</SPAN> Excel.Worksheet<br>    <br>    <br>    <SPAN style="color:#007F00">'// create a new workbook with a test range</SPAN><br>    <SPAN style="color:#00007F">Set</SPAN> wbNew = Workbooks.Add(XlWBATemplate.xlWBATWorksheet)<br>    <SPAN style="color:#00007F">Set</SPAN> wsNew = wbNew.Worksheets(1)<br>    <SPAN style="color:#00007F">Set</SPAN> rngDemo = wsNew.Range("A1:K25")<br>    <br>    <SPAN style="color:#00007F">With</SPAN> rngDemo<br>        <SPAN style="color:#007F00">'// a 33% chance we'll get an "X" in any particular cell.</SPAN><br>        .Formula = "=IF(RAND() < 0.33,""X"",0)"<br>        .Formula = .Value<br>        .HorizontalAlignment = XlHAlign.xlHAlignCenter<br>        <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">Resume</SPAN> <SPAN style="color:#00007F">Next</SPAN><br>        .SpecialCells(xlCellTypeConstants, XlSpecialCellsValue.xlNumbers).Clear<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>        <br>    <SPAN style="color:#007F00">'// run our test code</SPAN><br>    <SPAN style="color:#00007F">Set</SPAN> rngColK = rngDemo.Columns("K")<br>    <br>    <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> celColK <SPAN style="color:#00007F">In</SPAN> rngColK.Cells<br>    <br>        <SPAN style="color:#00007F">Set</SPAN> celEndLeft = celColK.End(xlToLeft)<br>        <SPAN style="color:#00007F">Set</SPAN> rngEndLeft = wsNew.Range(cel<SPAN style="color:#00007F">End</SPAN>Left, celColK)<br>        <br>        rngEndLeft.Interior.Color = vbYellow<br>        <br>    <SPAN style="color:#00007F">Next</SPAN> celColK<br><br>End <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Last edited:
Upvote 0

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,224,828
Messages
6,181,204
Members
453,022
Latest member
RobertV1609

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