Use code in a single spreadsheet

marreco

Well-known Member
Joined
Jan 1, 2011
Messages
609
Office Version
  1. 2010
Platform
  1. Windows
Good night!

Personally, i have to request your help to solve a problem...

The code of this file is designed for use in a database separate worksheet.

What i want is to use all features but in a single spreadsheet.

Follwos the attachment....

http://www.4shared.com/file/BeTVtJWQ...to_Insumo.html

Thanks
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
most people don't like to download files from new users. Please post the code, and tell us how you want it to be changed.
 
Upvote 0
...The code is very large.
Public Const nomePlanilhaCadastro As String = "Fornecedores"
Public Const nomePlanilhaProdutos As String = "Produtos"
Public Const nomePlanilhaMovimento As String = "Movimentacao"
Public Const nomePlanilhaGrafico As String = "Charts"

'Os objetos Worksheet representam as planilhas
Public wsCadastro As Worksheet 'Planilha Fornecedores
Public wsProdutos As Worksheet 'Planilha Produtos
Public wsMovimento As Worksheet 'Planilha Movimentacao
Public wsGrafico As Worksheet 'Planilha Graficos


'Workbook representa uma pasta de trabalho
Public wbCadastro As Workbook 'ARQUIVO_DADOS = Dados_BDs.xls

Public sConsulta As Boolean
Public xClose As Boolean

'Alterado para para Public, para poder ser usado em todos os Formulários
Public Sub FecharBD(Cancel As Integer, CloseMode As Integer)
'fecha a planilha de dados, se estiver aberta
If Not wbCadastro Is Nothing Then
wbCadastro.Saved = True
wbCadastro.Close SaveChanges:=False
End If

Set wbCadastro = Nothing
End Sub

'Alterado para para Public, para poder ser usado em todos os Formulários
Public Sub DefinePlanilhaDados()
Dim abrirArquivo As Boolean
Dim wb As Workbook
Dim caminhoCompleto As String
Dim ARQUIVO_DADOS As String
Dim PASTA_DADOS As String

abrirArquivo = True
'sConsulta = False
ARQUIVO_DADOS = Range("ARQUIVO_DADOS").Value
PASTA_DADOS = Range("PASTA_DADOS").Value

If ThisWorkbook.Name <> ARQUIVO_DADOS Then
'monta a string do caminho completo
If PASTA_DADOS = vbNullString Or PASTA_DADOS = "" Then
caminhoCompleto = Replace(ThisWorkbook.FullName, ThisWorkbook.Name, vbNullString) & ARQUIVO_DADOS
Else
If Right(PASTA_DADOS, 1) = "\" Then
caminhoCompleto = PASTA_DADOS & ARQUIVO_DADOS
Else
caminhoCompleto = PASTA_DADOS & "\" & ARQUIVO_DADOS
End If
End If

'verifica se o arquivo não está aberto
For Each wb In Application.Workbooks
If wb.Name = ARQUIVO_DADOS Then
abrirArquivo = False
Exit For
End If
Next

'atribui o arquivo
If abrirArquivo Then
Set wbCadastro = Workbooks.Open(FileName:=caminhoCompleto, ReadOnly:=True)
Else
Set wbCadastro = Workbooks(ARQUIVO_DADOS)
End If
Else
Set wbCadastro = ThisWorkbook
End If

'Referencia as 3 Planilhas da pasta wbCadastro
Set wsCadastro = wbCadastro.Worksheets(nomePlanilhaCadastro) 'Planilha Fornecedores
Set wsProdutos = wbCadastro.Worksheets(nomePlanilhaProdutos) 'Planilha Produtos
Set wsMovimento = wbCadastro.Worksheets(nomePlanilhaMovimento) 'Planilha Movimentacao
Set wsGrafico = wbCadastro.Worksheets(nomePlanilhaGrafico)

'oculta o arquivo de dados
wbCadastro.Windows(1).Visible = False

End Sub
 
Upvote 0
hrm.... this is NOT in English. Not sure how much I can help you.

What part of the code do you need to change?
 
Upvote 0
Good Night!

I would use the code to run on only one workbook, the code take the information in UseForm which is in a workbook 1 and saved within the worbook 2.

For you to better understand the code you should see my excel file.
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,544
Members
452,925
Latest member
duyvmex

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top