Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Select sheet from cell value

I would like to set the historyWks by the value in a cell.eg wks "Input"
Range D3. This would allow me to input the data to the selected sheet, as in
Rnd1, Rnd2 etc.
TKU
Harry

Sub UpdateLogWorksheet()

Dim historyWks As Worksheet
Dim inputWks As Worksheet
Dim Rnd2 As Worksheet
Dim nextRow As Long
Dim oCol As Long
Dim ComboBox9 As Variant
Dim myRng As Range
Dim myCopy As String
Dim myCell As Range

'cells to copy from Input sheet - some contain formulas
myCopy = "D3,D5,D7,D9,D11,D13,D15,D17,D19"

Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("Data")
With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With

With inputWks
Set myRng = .Range(myCopy)

If Application.CountA(myRng) < myRng.Cells.Count Then
MsgBox "Please fill in all the cells!"
Exit Sub
End If
End With

With historyWks
With .Cells(nextRow, "A")
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
.Cells(nextRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
historyWks.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With

'clear input cells that contain constants
With inputWks
On Error Resume Next
With .Range(myCopy).Cells.SpecialCells(xlCellTypeConsta nts)
.ClearContents
Application.GoTo .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Select sheet from cell value

I think...

Change this line:
Set historyWks = Worksheets("Data")
to
Set historyWks = Worksheets("Input").range("D3").value

Or to add a bit of validity...

set historywks = nothing
on error resume next
Set historyWks = Worksheets("Input").range("D3").value
on error goto 0

if historywks is nothing then
msgbox "D3 on Input doesn't contain a good worksheet name"
exit sub
end if



Grid wrote:

I would like to set the historyWks by the value in a cell.eg wks "Input"
Range D3. This would allow me to input the data to the selected sheet, as in
Rnd1, Rnd2 etc.
TKU
Harry

Sub UpdateLogWorksheet()

Dim historyWks As Worksheet
Dim inputWks As Worksheet
Dim Rnd2 As Worksheet
Dim nextRow As Long
Dim oCol As Long
Dim ComboBox9 As Variant
Dim myRng As Range
Dim myCopy As String
Dim myCell As Range

'cells to copy from Input sheet - some contain formulas
myCopy = "D3,D5,D7,D9,D11,D13,D15,D17,D19"

Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("Data")
With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With

With inputWks
Set myRng = .Range(myCopy)

If Application.CountA(myRng) < myRng.Cells.Count Then
MsgBox "Please fill in all the cells!"
Exit Sub
End If
End With

With historyWks
With .Cells(nextRow, "A")
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
.Cells(nextRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
historyWks.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With

'clear input cells that contain constants
With inputWks
On Error Resume Next
With .Range(myCopy).Cells.SpecialCells(xlCellTypeConsta nts)
.ClearContents
Application.GoTo .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Select sheet from cell value

Sorry dave, I must be doing something wrong. I receive 424 "Object required"
or "D3 on Input doesn't contain a good worksheet name". What am I doing wrong

"Grid" wrote:

I would like to set the historyWks by the value in a cell.eg wks "Input"
Range D3. This would allow me to input the data to the selected sheet, as in
Rnd1, Rnd2 etc.
TKU
Harry

Sub UpdateLogWorksheet()

Dim historyWks As Worksheet
Dim inputWks As Worksheet
Dim Rnd2 As Worksheet
Dim nextRow As Long
Dim oCol As Long
Dim ComboBox9 As Variant
Dim myRng As Range
Dim myCopy As String
Dim myCell As Range

'cells to copy from Input sheet - some contain formulas
myCopy = "D3,D5,D7,D9,D11,D13,D15,D17,D19"

Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("Data")
With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With

With inputWks
Set myRng = .Range(myCopy)

If Application.CountA(myRng) < myRng.Cells.Count Then
MsgBox "Please fill in all the cells!"
Exit Sub
End If
End With

With historyWks
With .Cells(nextRow, "A")
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
.Cells(nextRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
historyWks.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With

'clear input cells that contain constants
With inputWks
On Error Resume Next
With .Range(myCopy).Cells.SpecialCells(xlCellTypeConsta nts)
.ClearContents
Application.GoTo .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Select sheet from cell value

You have to put the name of a worksheet that already exists in that workbook in
D3 of the Input worksheet.

My first guess is that you mistyped the name (watch out for leading/trailing
embedded spaces).



Grid wrote:

Sorry dave, I must be doing something wrong. I receive 424 "Object required"
or "D3 on Input doesn't contain a good worksheet name". What am I doing wrong

"Grid" wrote:

I would like to set the historyWks by the value in a cell.eg wks "Input"
Range D3. This would allow me to input the data to the selected sheet, as in
Rnd1, Rnd2 etc.
TKU
Harry

Sub UpdateLogWorksheet()

Dim historyWks As Worksheet
Dim inputWks As Worksheet
Dim Rnd2 As Worksheet
Dim nextRow As Long
Dim oCol As Long
Dim ComboBox9 As Variant
Dim myRng As Range
Dim myCopy As String
Dim myCell As Range

'cells to copy from Input sheet - some contain formulas
myCopy = "D3,D5,D7,D9,D11,D13,D15,D17,D19"

Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("Data")
With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With

With inputWks
Set myRng = .Range(myCopy)

If Application.CountA(myRng) < myRng.Cells.Count Then
MsgBox "Please fill in all the cells!"
Exit Sub
End If
End With

With historyWks
With .Cells(nextRow, "A")
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
.Cells(nextRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
historyWks.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With

'clear input cells that contain constants
With inputWks
On Error Resume Next
With .Range(myCopy).Cells.SpecialCells(xlCellTypeConsta nts)
.ClearContents
Application.GoTo .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With
End Sub


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Select sheet from cell value

Sorry Dave, still doesn't work. I can populate the combo with the sheet names
or just type 1 in and still get the same errors.

"Dave Peterson" wrote:

You have to put the name of a worksheet that already exists in that workbook in
D3 of the Input worksheet.

My first guess is that you mistyped the name (watch out for leading/trailing
embedded spaces).



Grid wrote:

Sorry dave, I must be doing something wrong. I receive 424 "Object required"
or "D3 on Input doesn't contain a good worksheet name". What am I doing wrong

"Grid" wrote:

I would like to set the historyWks by the value in a cell.eg wks "Input"
Range D3. This would allow me to input the data to the selected sheet, as in
Rnd1, Rnd2 etc.
TKU
Harry

Sub UpdateLogWorksheet()

Dim historyWks As Worksheet
Dim inputWks As Worksheet
Dim Rnd2 As Worksheet
Dim nextRow As Long
Dim oCol As Long
Dim ComboBox9 As Variant
Dim myRng As Range
Dim myCopy As String
Dim myCell As Range

'cells to copy from Input sheet - some contain formulas
myCopy = "D3,D5,D7,D9,D11,D13,D15,D17,D19"

Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("Data")
With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With

With inputWks
Set myRng = .Range(myCopy)

If Application.CountA(myRng) < myRng.Cells.Count Then
MsgBox "Please fill in all the cells!"
Exit Sub
End If
End With

With historyWks
With .Cells(nextRow, "A")
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
.Cells(nextRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
historyWks.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With

'clear input cells that contain constants
With inputWks
On Error Resume Next
With .Range(myCopy).Cells.SpecialCells(xlCellTypeConsta nts)
.ClearContents
Application.GoTo .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With
End Sub


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Select sheet from cell value

If you type 1 in the cell and that cell is formatted as general, then the code
will use worksheets(1)--the leftmost worksheet.

If you're trying to put the data on a worksheet named 1, then use:

set historywks = nothing
on error resume next
Set historyWks = cstr(Worksheets("Input").range("D3").value)
on error goto 0

if historywks is nothing then
msgbox "D3 on Input doesn't contain a good worksheet name"
exit sub
end if

If that doesn't help...

What kind of combobox did you use?

Did you use a combobox from the Control toolbox toolbar?
Did you use a dropdown from the Forms toolbar?
Did you use data|validation?

What's in D3 and what's the name of the worksheet that you expected to be
populated--they have to match character by character (upper/lower case doesn't
matter, though).



Grid wrote:

Sorry Dave, still doesn't work. I can populate the combo with the sheet names
or just type 1 in and still get the same errors.

"Dave Peterson" wrote:

You have to put the name of a worksheet that already exists in that workbook in
D3 of the Input worksheet.

My first guess is that you mistyped the name (watch out for leading/trailing
embedded spaces).



Grid wrote:

Sorry dave, I must be doing something wrong. I receive 424 "Object required"
or "D3 on Input doesn't contain a good worksheet name". What am I doing wrong

"Grid" wrote:

I would like to set the historyWks by the value in a cell.eg wks "Input"
Range D3. This would allow me to input the data to the selected sheet, as in
Rnd1, Rnd2 etc.
TKU
Harry

Sub UpdateLogWorksheet()

Dim historyWks As Worksheet
Dim inputWks As Worksheet
Dim Rnd2 As Worksheet
Dim nextRow As Long
Dim oCol As Long
Dim ComboBox9 As Variant
Dim myRng As Range
Dim myCopy As String
Dim myCell As Range

'cells to copy from Input sheet - some contain formulas
myCopy = "D3,D5,D7,D9,D11,D13,D15,D17,D19"

Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("Data")
With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With

With inputWks
Set myRng = .Range(myCopy)

If Application.CountA(myRng) < myRng.Cells.Count Then
MsgBox "Please fill in all the cells!"
Exit Sub
End If
End With

With historyWks
With .Cells(nextRow, "A")
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
.Cells(nextRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
historyWks.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With

'clear input cells that contain constants
With inputWks
On Error Resume Next
With .Range(myCopy).Cells.SpecialCells(xlCellTypeConsta nts)
.ClearContents
Application.GoTo .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With
End Sub


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Select sheet from cell value

Sorry Dave, still no joy. The sheets are named Rnd1, Rnd2 etc. Your code with
the Cstr generated a type mismatch, deleted Cstr and get an object required
mssage. Typing Rnd1 into box makes no diff, match perfectly. Combo from the
control t/b, nothing from Forms t/b and no validation.
TKU for your help

"Dave Peterson" wrote:

If you type 1 in the cell and that cell is formatted as general, then the code
will use worksheets(1)--the leftmost worksheet.

If you're trying to put the data on a worksheet named 1, then use:

set historywks = nothing
on error resume next
Set historyWks = cstr(Worksheets("Input").range("D3").value)
on error goto 0

if historywks is nothing then
msgbox "D3 on Input doesn't contain a good worksheet name"
exit sub
end if

If that doesn't help...

What kind of combobox did you use?

Did you use a combobox from the Control toolbox toolbar?
Did you use a dropdown from the Forms toolbar?
Did you use data|validation?

What's in D3 and what's the name of the worksheet that you expected to be
populated--they have to match character by character (upper/lower case doesn't
matter, though).



Grid wrote:

Sorry Dave, still doesn't work. I can populate the combo with the sheet names
or just type 1 in and still get the same errors.

"Dave Peterson" wrote:

You have to put the name of a worksheet that already exists in that workbook in
D3 of the Input worksheet.

My first guess is that you mistyped the name (watch out for leading/trailing
embedded spaces).



Grid wrote:

Sorry dave, I must be doing something wrong. I receive 424 "Object required"
or "D3 on Input doesn't contain a good worksheet name". What am I doing wrong

"Grid" wrote:

I would like to set the historyWks by the value in a cell.eg wks "Input"
Range D3. This would allow me to input the data to the selected sheet, as in
Rnd1, Rnd2 etc.
TKU
Harry

Sub UpdateLogWorksheet()

Dim historyWks As Worksheet
Dim inputWks As Worksheet
Dim Rnd2 As Worksheet
Dim nextRow As Long
Dim oCol As Long
Dim ComboBox9 As Variant
Dim myRng As Range
Dim myCopy As String
Dim myCell As Range

'cells to copy from Input sheet - some contain formulas
myCopy = "D3,D5,D7,D9,D11,D13,D15,D17,D19"

Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("Data")
With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With

With inputWks
Set myRng = .Range(myCopy)

If Application.CountA(myRng) < myRng.Cells.Count Then
MsgBox "Please fill in all the cells!"
Exit Sub
End If
End With

With historyWks
With .Cells(nextRow, "A")
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
.Cells(nextRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
historyWks.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With

'clear input cells that contain constants
With inputWks
On Error Resume Next
With .Range(myCopy).Cells.SpecialCells(xlCellTypeConsta nts)
.ClearContents
Application.GoTo .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With
End Sub

--

Dave Peterson


--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Select sheet from cell value

I see my mistake:

Set HistoryWks = Worksheets(CStr(Worksheets("Input").Range("D3").Va lue))

Sorry.



Grid wrote:

Sorry Dave, still no joy. The sheets are named Rnd1, Rnd2 etc. Your code with
the Cstr generated a type mismatch, deleted Cstr and get an object required
mssage. Typing Rnd1 into box makes no diff, match perfectly. Combo from the
control t/b, nothing from Forms t/b and no validation.
TKU for your help

"Dave Peterson" wrote:

If you type 1 in the cell and that cell is formatted as general, then the code
will use worksheets(1)--the leftmost worksheet.

If you're trying to put the data on a worksheet named 1, then use:

set historywks = nothing
on error resume next
Set historyWks = cstr(Worksheets("Input").range("D3").value)
on error goto 0

if historywks is nothing then
msgbox "D3 on Input doesn't contain a good worksheet name"
exit sub
end if

If that doesn't help...

What kind of combobox did you use?

Did you use a combobox from the Control toolbox toolbar?
Did you use a dropdown from the Forms toolbar?
Did you use data|validation?

What's in D3 and what's the name of the worksheet that you expected to be
populated--they have to match character by character (upper/lower case doesn't
matter, though).



Grid wrote:

Sorry Dave, still doesn't work. I can populate the combo with the sheet names
or just type 1 in and still get the same errors.

"Dave Peterson" wrote:

You have to put the name of a worksheet that already exists in that workbook in
D3 of the Input worksheet.

My first guess is that you mistyped the name (watch out for leading/trailing
embedded spaces).



Grid wrote:

Sorry dave, I must be doing something wrong. I receive 424 "Object required"
or "D3 on Input doesn't contain a good worksheet name". What am I doing wrong

"Grid" wrote:

I would like to set the historyWks by the value in a cell.eg wks "Input"
Range D3. This would allow me to input the data to the selected sheet, as in
Rnd1, Rnd2 etc.
TKU
Harry

Sub UpdateLogWorksheet()

Dim historyWks As Worksheet
Dim inputWks As Worksheet
Dim Rnd2 As Worksheet
Dim nextRow As Long
Dim oCol As Long
Dim ComboBox9 As Variant
Dim myRng As Range
Dim myCopy As String
Dim myCell As Range

'cells to copy from Input sheet - some contain formulas
myCopy = "D3,D5,D7,D9,D11,D13,D15,D17,D19"

Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("Data")
With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With

With inputWks
Set myRng = .Range(myCopy)

If Application.CountA(myRng) < myRng.Cells.Count Then
MsgBox "Please fill in all the cells!"
Exit Sub
End If
End With

With historyWks
With .Cells(nextRow, "A")
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
.Cells(nextRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
historyWks.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With

'clear input cells that contain constants
With inputWks
On Error Resume Next
With .Range(myCopy).Cells.SpecialCells(xlCellTypeConsta nts)
.ClearContents
Application.GoTo .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With
End Sub

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Select sheet from cell value

Works perfectly Dave. Thank you so very much for your patience and
assistance, it is greatly appreciated.
Grid

"Dave Peterson" wrote:

I see my mistake:

Set HistoryWks = Worksheets(CStr(Worksheets("Input").Range("D3").Va lue))

Sorry.



Grid wrote:

Sorry Dave, still no joy. The sheets are named Rnd1, Rnd2 etc. Your code with
the Cstr generated a type mismatch, deleted Cstr and get an object required
mssage. Typing Rnd1 into box makes no diff, match perfectly. Combo from the
control t/b, nothing from Forms t/b and no validation.
TKU for your help

"Dave Peterson" wrote:

If you type 1 in the cell and that cell is formatted as general, then the code
will use worksheets(1)--the leftmost worksheet.

If you're trying to put the data on a worksheet named 1, then use:

set historywks = nothing
on error resume next
Set historyWks = cstr(Worksheets("Input").range("D3").value)
on error goto 0

if historywks is nothing then
msgbox "D3 on Input doesn't contain a good worksheet name"
exit sub
end if

If that doesn't help...

What kind of combobox did you use?

Did you use a combobox from the Control toolbox toolbar?
Did you use a dropdown from the Forms toolbar?
Did you use data|validation?

What's in D3 and what's the name of the worksheet that you expected to be
populated--they have to match character by character (upper/lower case doesn't
matter, though).



Grid wrote:

Sorry Dave, still doesn't work. I can populate the combo with the sheet names
or just type 1 in and still get the same errors.

"Dave Peterson" wrote:

You have to put the name of a worksheet that already exists in that workbook in
D3 of the Input worksheet.

My first guess is that you mistyped the name (watch out for leading/trailing
embedded spaces).



Grid wrote:

Sorry dave, I must be doing something wrong. I receive 424 "Object required"
or "D3 on Input doesn't contain a good worksheet name". What am I doing wrong

"Grid" wrote:

I would like to set the historyWks by the value in a cell.eg wks "Input"
Range D3. This would allow me to input the data to the selected sheet, as in
Rnd1, Rnd2 etc.
TKU
Harry

Sub UpdateLogWorksheet()

Dim historyWks As Worksheet
Dim inputWks As Worksheet
Dim Rnd2 As Worksheet
Dim nextRow As Long
Dim oCol As Long
Dim ComboBox9 As Variant
Dim myRng As Range
Dim myCopy As String
Dim myCell As Range

'cells to copy from Input sheet - some contain formulas
myCopy = "D3,D5,D7,D9,D11,D13,D15,D17,D19"

Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("Data")
With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With

With inputWks
Set myRng = .Range(myCopy)

If Application.CountA(myRng) < myRng.Cells.Count Then
MsgBox "Please fill in all the cells!"
Exit Sub
End If
End With

With historyWks
With .Cells(nextRow, "A")
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
.Cells(nextRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
historyWks.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With

'clear input cells that contain constants
With inputWks
On Error Resume Next
With .Range(myCopy).Cells.SpecialCells(xlCellTypeConsta nts)
.ClearContents
Application.GoTo .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With
End Sub

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson

  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Select sheet from cell value

Nope. Thanks for your patience. It was my mistake (lack of a simple test)!



Grid wrote:

Works perfectly Dave. Thank you so very much for your patience and
assistance, it is greatly appreciated.
Grid

"Dave Peterson" wrote:

I see my mistake:

Set HistoryWks = Worksheets(CStr(Worksheets("Input").Range("D3").Va lue))

Sorry.



Grid wrote:

Sorry Dave, still no joy. The sheets are named Rnd1, Rnd2 etc. Your code with
the Cstr generated a type mismatch, deleted Cstr and get an object required
mssage. Typing Rnd1 into box makes no diff, match perfectly. Combo from the
control t/b, nothing from Forms t/b and no validation.
TKU for your help

"Dave Peterson" wrote:

If you type 1 in the cell and that cell is formatted as general, then the code
will use worksheets(1)--the leftmost worksheet.

If you're trying to put the data on a worksheet named 1, then use:

set historywks = nothing
on error resume next
Set historyWks = cstr(Worksheets("Input").range("D3").value)
on error goto 0

if historywks is nothing then
msgbox "D3 on Input doesn't contain a good worksheet name"
exit sub
end if

If that doesn't help...

What kind of combobox did you use?

Did you use a combobox from the Control toolbox toolbar?
Did you use a dropdown from the Forms toolbar?
Did you use data|validation?

What's in D3 and what's the name of the worksheet that you expected to be
populated--they have to match character by character (upper/lower case doesn't
matter, though).



Grid wrote:

Sorry Dave, still doesn't work. I can populate the combo with the sheet names
or just type 1 in and still get the same errors.

"Dave Peterson" wrote:

You have to put the name of a worksheet that already exists in that workbook in
D3 of the Input worksheet.

My first guess is that you mistyped the name (watch out for leading/trailing
embedded spaces).



Grid wrote:

Sorry dave, I must be doing something wrong. I receive 424 "Object required"
or "D3 on Input doesn't contain a good worksheet name". What am I doing wrong

"Grid" wrote:

I would like to set the historyWks by the value in a cell.eg wks "Input"
Range D3. This would allow me to input the data to the selected sheet, as in
Rnd1, Rnd2 etc.
TKU
Harry

Sub UpdateLogWorksheet()

Dim historyWks As Worksheet
Dim inputWks As Worksheet
Dim Rnd2 As Worksheet
Dim nextRow As Long
Dim oCol As Long
Dim ComboBox9 As Variant
Dim myRng As Range
Dim myCopy As String
Dim myCell As Range

'cells to copy from Input sheet - some contain formulas
myCopy = "D3,D5,D7,D9,D11,D13,D15,D17,D19"

Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("Data")
With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With

With inputWks
Set myRng = .Range(myCopy)

If Application.CountA(myRng) < myRng.Cells.Count Then
MsgBox "Please fill in all the cells!"
Exit Sub
End If
End With

With historyWks
With .Cells(nextRow, "A")
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
.Cells(nextRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
historyWks.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With

'clear input cells that contain constants
With inputWks
On Error Resume Next
With .Range(myCopy).Cells.SpecialCells(xlCellTypeConsta nts)
.ClearContents
Application.GoTo .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With
End Sub

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using formulas to select cells (Ex: Select every nth cell in a col Lakeview Photographic Services Excel Discussion (Misc queries) 2 March 15th 07 02:17 PM
View, scroll and select a cell value from another Excel sheet? benb Excel Worksheet Functions 1 October 12th 06 05:48 AM
How do I select price from sheet.b where sheet.a part no = sheet.b Sonny Excel Worksheet Functions 4 April 4th 06 05:08 PM
Use Sheet CodeNames to Select Sheet in Different Workbook Randy Excel Discussion (Misc queries) 1 June 10th 05 12:17 AM
Macro, select Sheet "Number", NOT Sheet Name DAA Excel Worksheet Functions 4 November 30th 04 05:29 PM


All times are GMT +1. The time now is 04:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"