Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merge cells

Status
Not open for further replies.

nnuswantari

Programmer
Nov 21, 2009
17
ID
Please tell me sintax to merge cells with macro in excel. Thanx
 
Did you try the macro recorder ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi nnuswantari,

I agree with PHV, but can I also ask why you want to merge cells? I have found that merged cells can create a lot of problems, and where appropriate now use Centre Across Selection instead.

Cheers, Glenn.

Beauty is in the eye of the beerholder.
 
ThichTraXanh, why playing with Selection ?
Range("A1:E1").MergeCells = True

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 



ThichTraXanh,

It is rarely a good practice to use the Select or Activate methods. The property or method can, in most cases, be applied directly to an object, with much better performance results.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
:) thanks guys, I didn't know that I can apply directly like that. Excel help shows with Selection. There is a weird thing that I try to understand why it happens that way, and only happen with sub not function.

Exam:
sub test(intX as integer, strY as string)
'do something
end sub

test 1, "this string"

It will give me a error like type mismatch, cann't pass byval...

Any idea???

 

Try then...
Code:
[b][red]
dim i as integer
i=1[/red][/b]
test [b][red]i[/red][/b], "this string"

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Code:
Sub test(intX As Integer, strY As String)
   'do something
MsgBox strY
End Sub

Sub Try()
test 1, "Yadda"
End Sub
works for me. Msgbox displays "Yadda".

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top