ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Newbie questions - probably simple (https://www.excelbanter.com/excel-programming/359601-newbie-questions-probably-simple.html)

Sonnich

Newbie questions - probably simple
 
Hi!

I have an excel doc, with a button, for which I need to know:

I need to open another file, which I like this
Workbooks.Open ("C:\test\somefile.xls")
- Is there a way that I can prompt for the filename?

The I copy data from that into my document. Like this

Workbooks(1).Sheets(1).Cells(i, j) =
Workbooks(2).Sheets(1).Cells(i, j)
Workbooks(1).Sheets(1).Cells(i, j).Font.Bold =
Workbooks(2).Sheets(1).Cells(i, j).Font.Bold

- How can I copy the widths of the cells, and the border (if any)?

And finally:

Is there a way to delete an entite row? (or coloumn?)

Is there a way to move/copy a row or coloumn?

BR
Sonnich


Bob Phillips[_6_]

Newbie questions - probably simple
 


"Sonnich" wrote in message
oups.com...
Hi!

I have an excel doc, with a button, for which I need to know:

I need to open another file, which I like this
Workbooks.Open ("C:\test\somefile.xls")
- Is there a way that I can prompt for the filename?


Look at GetOpenFilename in VBA Help

The I copy data from that into my document. Like this

Workbooks(1).Sheets(1).Cells(i, j) =
Workbooks(2).Sheets(1).Cells(i, j)
Workbooks(1).Sheets(1).Cells(i, j).Font.Bold =
Workbooks(2).Sheets(1).Cells(i, j).Font.Bold

- How can I copy the widths of the cells, and the border (if any)?


Workbooks(1).Sheets(1).Cells(i, j).Copy
Workbooks(2).Sheets(1).Cells(i, j).Paste PasteSpecial:=xlPasteAll



Sonnich

Newbie questions - probably simple
 
I need to open another file, which I like this
Workbooks.Open ("C:\test\somefile.xls")
- Is there a way that I can prompt for the filename?

Look at GetOpenFilename in VBA Help


Thanks that worked


The I copy data from that into my document. Like this
Workbooks(1).Sheets(1).Cells(i, j) =
Workbooks(2).Sheets(1).Cells(i, j)
Workbooks(1).Sheets(1).Cells(i, j).Font.Bold =
Workbooks(2).Sheets(1).Cells(i, j).Font.Bold
- How can I copy the widths of the cells, and the border (if any)?

Workbooks(1).Sheets(1).Cells(i, j).Copy
Workbooks(2).Sheets(1).Cells(i, j).Paste PasteSpecial:=xlPasteAll


It works,, but I resizes all the cells into something odd, even the
height changes. Besides it does not look good when working.
I found this to work, but I still need to get the coloumn widths
correctly.
Workbooks(2).Sheets(1).Range("a1:h31").Copy
(Workbooks(1).Sheets(1).Range("a1"))

BESIDES, I'd like to know:

1) how can I delete an entire row (e.g. 16)?

2) how do I know the size of my sheet? For some H is the last one used,
for others I or L. There must be a function for this.

3) is there a way to move an entire coloumn, or insert one? Or to
delete one (same as row I asume)?

BR
Sonnich


Ikaabod[_18_]

Newbie questions - probably simple
 

I can answer 1 and 3 easily enough:

1) Rows("16:16").EntireRow.Delete
2) I'll let someone else explain this one. My methods for this ar
very primative.
3) Columns("E:E").EntireColumn.Insert
Columns("H:H").EntireColumn.Cu
Destination:=Columns("E:E").EntireColumn. _
EntireColumn

Hope that helps.

-Ikaabod


Sonnich Wrote:


BESIDES, I'd like to know:

1) how can I delete an entire row (e.g. 16)?

2) how do I know the size of my sheet? For some H is the last on
used,
for others I or L. There must be a function for this.

3) is there a way to move an entire coloumn, or insert one? Or to
delete one (same as row I asume)?

BR
Sonnic


--
Ikaabo
-----------------------------------------------------------------------
Ikaabod's Profile: http://www.excelforum.com/member.php...fo&userid=3337
View this thread: http://www.excelforum.com/showthread.php?threadid=53555


jodleren

Newbie questions - probably simple
 
One more to go...

I can set a string, but how do I set a number as it was a string, like:

Workbooks(1).Sheets(1).Cells(i, j) = "Hello world"

and

Workbooks(1).Sheets(1).Cells(i, j) = "1." ' this is some kind of
header

BR
Sonnich



All times are GMT +1. The time now is 11:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com