Macro Trouble

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to record a macro that allows me to select a certain range of cells and open a data form for that selection. I recorded a macro doing this, and when ran it, seen it was opening the data form for the entire sheet and not the selection. I looked at the macro in VB and this is it:

Range("A5:B8").Select
ActiveSheet.ShowDataForm

So it is selecting the cells I want, but running it for the entire sheet after all.
I tried using this instead:

Range("A5:B8").Select
Selection.ShowDataForm

But I am getting an error message of "Object doesn't support this property or method". Does that mean its impossible to do this with a macro if it doesnt support running the selection? If so, is there another simple and easy way to perform this funcion without using a macro?
 
Alan,

ShowDataForm works on a worksheet not a range, so you don't get a choice.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Alan said:
I want to record a macro that allows me to select a certain range of cells
and open a data form for that selection. I recorded a macro doing this, and
when ran it, seen it was opening the data form for the entire sheet and not
the selection. I looked at the macro in VB and this is it:
Range("A5:B8").Select
ActiveSheet.ShowDataForm

So it is selecting the cells I want, but running it for the entire sheet after all.
I tried using this instead:

Range("A5:B8").Select
Selection.ShowDataForm

But I am getting an error message of "Object doesn't support this property
or method". Does that mean its impossible to do this with a macro if it
doesnt support running the selection? If so, is there another simple and
easy way to perform this funcion without using a macro?
 
One way (assuming you want to just enter data for columns A & B on the
data form):

Public Sub DataFormAB()
With ActiveSheet
.Columns("C:IV").EntireColumn.Hidden = True
.ShowDataForm
.Columns("C:IV").EntireColumn.Hidden = False
End With
End Sub
 
Back
Top