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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Can you post your code and explain what exactly is not working?
 

orbea_adam

Well-known Member
Joined
Nov 15, 2005
Messages
500
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
 

billy7978

New Member
Joined
Sep 6, 2006
Messages
9
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.
 

orbea_adam

Well-known Member
Joined
Nov 15, 2005
Messages
500

ADVERTISEMENT

hmm, I'm no bueno with VBA. HOTPEPPER, you there?
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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?
 

billy7978

New Member
Joined
Sep 6, 2006
Messages
9

ADVERTISEMENT

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
.
 

Forum statistics

Threads
1,136,354
Messages
5,675,303
Members
419,560
Latest member
g3org

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
Top