ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro to bring up Data Form (https://www.excelbanter.com/excel-discussion-misc-queries/245915-macro-bring-up-data-form.html)

jk

Macro to bring up Data Form
 
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 dataform).

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 DataForm 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!

Dave Peterson

Macro to bring up Data Form
 
Saved from a previous post...

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

http://support.microsoft.com/default...;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.

jk wrote:

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 dataform).

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 DataForm 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!


--

Dave Peterson


All times are GMT +1. The time now is 08:44 PM.

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