why do I have to reopen my project to use excel?

billy7978

New Member
Joined
Sep 6, 2006
Messages
9
hi friends. I really have a serious problem. maybe it is easy for you but it is not for me.

I am leading excell with vb.
I have some merged cells. when I run the project it works. but if
I click button the second time it does not work. I see that the merged cells are unmerged. so I have to close my project and run again.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Can you post your code and explain what exactly is not working?
 
Upvote 0
billy7978,
Welcome to Mr Excel. "leading"? Oh, learning...I have learned from others in this forum that using merged cells is not a good practice. Instead use: Center Across Selection.
Adam
 
Upvote 0
hepl please

Can you post your code and explain what exactly is not working?

command1_click

excell.Range(Cells(1, 1), Cells(1, 4)).Merge

excell.Range("A" & 1).Value = MDIForm1.Text24.Text excel.Columns
WrapText = True
end sub

when i run it for the first time it works. but again if i click the button it does not work so i have to reopen my project. when i reopen it , it again works good but only once.... then i have to close my project and open it again.
 
Upvote 0
Not sure how it is working the first time, you don't define excell anywhere.

Is MDIForm1 a regular userform? What is the reference to excel.Columns?

You are not using WrapText as a property for a range object. What range did you want WrapText set for?
 
Upvote 0
closing problem

Not sure how it is working the first time, you don't define excell anywhere.

Is MDIForm1 a regular userform? What is the reference to excel.Columns?

You are not using WrapText as a property for a range object. What range did you want WrapText set for?

Dim exl As Object
Dim xlWb As Object



command1_click
Set exl = CreateObject("Excel.Application")
exl.Visible = True


Set xlWb = excell.Workbooks.Add
Set exl = xlWb.Worksheets(1)

exl.Range(Cells(1, 1), Cells(1, 4)).Merge '....( a1 to a4)

exl.Range("A" & 1).Value = "a long adress there is no problem here"
'exl.Columns WrapText = True (it is not so important)
end sub

in this way it works good but just once . if i click second time the cells are unmerged. so i have to reopen my project. after reopening it works again. but again once
.
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,818
Members
449,049
Latest member
cybersurfer5000

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