T
tango
thanks alot sharad. few things i need yr further explanation.
1) for point no 1, you mean i need to do import in vbe for the first
time? when i export or import, thisworkbook and sheets the type is
cls. what is class?
2) for point no 2, what do you mean by template? do you mean make a
copy of the workbook and clear the contents and remain the vba?
3) any vba example of password box when open the workbook and the
password is not hardcode in vba.
thanks alot
1) For the existing project since the excel files are already created
on
each machine,
you can do import on each file.
2) For the next project, you can create a template having your VBE
code in
it and circulate to
every one. For the next projects, they should use this template .
3) Instead of adding command button in a sheet, add a new button on
the tool
bar,
and assing the macro to it. So the button will be always available to
the
use on the tool bar.
Transfering data from all worksheets:
Below code gets a valid sheet no. from the user and transfers contents
of
Range("A1") from every sheet (except the sheet for sheet no. entered )
in
to
the sheet for sheet no. entered, in to Column F.
Sub Test()
Dim getNum As String, mySheetNum As Integer
Dim myRange As Range, nCount As Integer
Dim totSheetNum As Integer
getSheetNum:
getNum = InputBox("Please enter the desitantion sheet number", _
"Sheet Numbar Required:")
If Len(getNum) = 0 Then Exit Sub
'i.e. if no data entered or user presses cancel, do noting.
If Not IsNumeric(getNum) Then
MsgBox "Please enter an Integer"
GoTo getSheetNum:
End If
'i.e. check if data entered is numeric or not if no ask again
If InStr(1, getNum, ".", vbTextCompare) > 0 Then
MsgBox "Please enter an Integer"
GoTo getSheetNum:
End If
'i.e check if the number entered has a "." in it if yes ask
'for an integer again
mySheetNum = Int(getNum)
totSheetNum = ThisWorkbook.Sheets.Count
If mySheetNum > totSheetNum Then
MsgBox "The sheet number you entered is not valid because" & _
" there are only " & totSheetNum & " sheets!" & Chr(13) & _
"Please enter a valid sheet number."
GoTo getSheetNum
End If
nCount = 1
For Each s In ThisWorkbook.Sheets
If Not s.Index = mySheetNum Then
Sheets(mySheetNum).Range("F" & nCount) = s.Range("A1")
nCount = nCount + 1
End If
Next
End Sub
1) for point no 1, you mean i need to do import in vbe for the first
time? when i export or import, thisworkbook and sheets the type is
cls. what is class?
2) for point no 2, what do you mean by template? do you mean make a
copy of the workbook and clear the contents and remain the vba?
3) any vba example of password box when open the workbook and the
password is not hardcode in vba.
thanks alot
1) For the existing project since the excel files are already created
on
each machine,
you can do import on each file.
2) For the next project, you can create a template having your VBE
code in
it and circulate to
every one. For the next projects, they should use this template .
3) Instead of adding command button in a sheet, add a new button on
the tool
bar,
and assing the macro to it. So the button will be always available to
the
use on the tool bar.
Transfering data from all worksheets:
Below code gets a valid sheet no. from the user and transfers contents
of
Range("A1") from every sheet (except the sheet for sheet no. entered )
in
to
the sheet for sheet no. entered, in to Column F.
Sub Test()
Dim getNum As String, mySheetNum As Integer
Dim myRange As Range, nCount As Integer
Dim totSheetNum As Integer
getSheetNum:
getNum = InputBox("Please enter the desitantion sheet number", _
"Sheet Numbar Required:")
If Len(getNum) = 0 Then Exit Sub
'i.e. if no data entered or user presses cancel, do noting.
If Not IsNumeric(getNum) Then
MsgBox "Please enter an Integer"
GoTo getSheetNum:
End If
'i.e. check if data entered is numeric or not if no ask again
If InStr(1, getNum, ".", vbTextCompare) > 0 Then
MsgBox "Please enter an Integer"
GoTo getSheetNum:
End If
'i.e check if the number entered has a "." in it if yes ask
'for an integer again
mySheetNum = Int(getNum)
totSheetNum = ThisWorkbook.Sheets.Count
If mySheetNum > totSheetNum Then
MsgBox "The sheet number you entered is not valid because" & _
" there are only " & totSheetNum & " sheets!" & Chr(13) & _
"Please enter a valid sheet number."
GoTo getSheetNum
End If
nCount = 1
For Each s In ThisWorkbook.Sheets
If Not s.Index = mySheetNum Then
Sheets(mySheetNum).Range("F" & nCount) = s.Range("A1")
nCount = nCount + 1
End If
Next
End Sub