How can i get the cells of a range i chose with the mouse??Is there any function?Do u know how can i do this...?plz i need help :loopain:
Get Cells Of A Range
-
-
-
Selected
What you can do is when you do invoke your macro, the selected cells can be access doing the following:
Worksheets("MySheet").Activate 'Activate the sheet with the selection
ActiveSheet.Selection.FooWith cells, you can do whatever you need to do in VBA to the cells.
You can also save the Range into a Range variable:Dim myRange as Range
myRange = ActiveSheet.Selection
-
i use visual basic to work with excel and dont recognize "range" variable definition...(sorry for my english :? )...what can i do?
-
Version
What version of VB are you using.
I can use the Range variable in 6.3
-
Quote from Jong
What version of VB are you using.
I can use the Range variable in 6.3
vb 6.0
i have to create a program that can take an excel file and present it with html(tables in html not excel in html)...the problem is that it must make html only the cells tha the user have chosen with the mouse...and i cannot find a way to take the selected cells...not the range...the first and the last cell... -
Hi,
If you are using VB6, the stand alone program, and want to manipulate Excel via code with early binding you will need to include a reference to the Excel Object library.
Something like Excel9.olbThis should then allow you to declare variables as type Range
-
Quote from Andy Pope
Hi,
If you are using VB6, the stand alone program, and want to manipulate Excel via code with early binding you will need to include a reference to the Excel Object library.
Something like Excel9.olbThis should then allow you to declare variables as type Range
well thnx i found it
but.....i get an error message when i write this...
Dim myrange As Excel.Range
myrange = ApExcel.Range("A1").Value = 11and i get
"object variable or with block variable not set"
help meeeeeeeeee
plzzzz!!!!
-
You have created an instance of excel, haven't you?
Or at least pointer to an open session.Dim appExcel as Excel.Application
Set appExcel = CreateObject("Excel.Application")or
Dim wbkTemp as Excel.Workbook
Set wbkTemp = GetObject("MyFile.xls")Have a look at this article
http://www.ozgrid.com/forum/showthread.php?t=19599Or this from Microsoft.
http://support.microsoft.com/d…aspx?scid=kb;en-us;219151 -
Quote from Andy Pope
You have created an instance of excel, haven't you?
Or at least pointer to an open session.Dim appExcel as Excel.Application
Set appExcel = CreateObject("Excel.Application")or
Dim wbkTemp as Excel.Workbook
Set wbkTemp = GetObject("MyFile.xls")Have a look at this article
http://www.ozgrid.com/forum/showthread.php?t=19599Or this from Microsoft.
http://support.microsoft.com/d…aspx?scid=kb;en-us;219151Dim ApExcel As Object
Dim a As StringPrivate Sub Command1_Click()
a = "c:\a.xls"
Set ApExcel = CreateObject("Excel.application")
ApExcel.Visible = True
ApExcel.Workbooks.Open (a)End Sub
thats what i have...can u give me suggestions or help to do it???i havent done anything yet....i really need help... :?
-
I suggest you try it as the code worked for me.
I simply open a new VB stand-alone project. Add a command button to the userform.
When I run the project and pressed the button it opened the workbook in another instance of excel.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!