Macro to bring up Data Form

J

jk

Hi,
I have an excel sheet with which I want a macro button to bring up the Data
Form (simply instead of going to the menu data>form).

ActiveSheet.ShowDataForm
End Sub

Problem is that I have a row above the column headings which has merged
cells and when the macro runs it seems to not like it. Although if I simply
goto Data>Form via the menu it works. I suspect I need to define range or to
exclude the row that has the merged cells rather than simply ActiveSheet. I
have tried but doing something wrong...

Please help!
 
D

Dave Peterson

Saved from a previous post...

Maybe your data doesn't start in the location excel expects:

http://support.microsoft.com/default.aspx?scid=KB;en-us;q110462
XL: ShowDataForm Method Fails If Data Can't Be Found

You can use code like this if you know (or can determine) the range:

Option Explicit
Sub testme01()
Dim LastRow as Long
Application.DisplayAlerts = False
With activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row
.Range("A4:x" & lastrow).Name = "'" & .Name & "'!database"
.ShowDataForm
End With
Application.DisplayAlerts = True
End Sub

I started in A4 until the last used row in column A, then extended it to columns
A:X of those rows.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top