Hello,
I have recently started to code a macro to help me repetitive data analysis with very few knowledge in coding languages.
I have came up with this code, the idea is that I import my data on the sheet "raw" then I select the different series of values and name them in a new sheet. Since I have different set of data with variable length I came up with this loop that ask me what to copy/paste but I don't really know how to set up the Loop Exit for when I don't have anymore data to select. For the moment I have tinkered something with a conditional exit but I have to select an empty cell and then the rest of the loop still go on thus overwriting on the previous series.
I hope that my intent is understandable and if you have any tips to make the code more elegant it would be very much appreciated.
Thanks.
I have recently started to code a macro to help me repetitive data analysis with very few knowledge in coding languages.
I have came up with this code, the idea is that I import my data on the sheet "raw" then I select the different series of values and name them in a new sheet. Since I have different set of data with variable length I came up with this loop that ask me what to copy/paste but I don't really know how to set up the Loop Exit for when I don't have anymore data to select. For the moment I have tinkered something with a conditional exit but I have to select an empty cell and then the rest of the loop still go on thus overwriting on the previous series.
I hope that my intent is understandable and if you have any tips to make the code more elegant it would be very much appreciated.
Thanks.
VBA Code:
Sub DataAnalysis()
'add new sheet
Sheets.Add(Before:=Worksheets("raw")).Name = "New"
Worksheets("New").Activate
With Sheets("New")
'negative value transfer
Dim negval As Range
Worksheets("raw").Activate
Set negval = Application.InputBox(Prompt:="Pick the neg values", Type:=8)
negval.Copy
Worksheets("New").Activate
Range("A2").PasteSpecial Paste:=xlPasteValues
Range("A1").Value = "neg"
Range("A6") = Application.WorksheetFunction.Average(Range("A2:A4"))
'peptides selection and transfer
Dim SerieValue As Range
Dim SerieName As String
Dim Condi As Boolean
Dim CondiConc As Boolean
Dim SerieLentgh As Integer
Dim i As Integer
i = 1
Do
'selection of series values
Worksheets("raw").Activate
Set SerieValue = Application.InputBox(Prompt:="Pick Serie or empty cell if no more serie", Type:=8)
'At the moment my way out of the loop is by selecting a single empty cell but then it mess a bit up with the rest of the loop
If Not IsEmpty(SerieValue) Then Condi = False
If IsEmpty(SerieValue) Then Condi = True
SerieLength = SerieValue.Rows.Count
Worksheets("New").Activate
SerieName = Application.InputBox(Prompt:="Please input serie name.", Type:=2)
SerieValue.Copy Destination:=Cells(3, i).Offset(0, 1)
Cells(1, i).Offset(0, 1).Value = SerieName
Range(Cells(1, i + 1), Cells(1, i + SerieLength)).Merge
'Range(Cells(1, i)).HorizontalAlignment = xlCenter
i = i + SerieLength
Loop Until Condi = True
Dim SheetName As String
SheetName = InputBox("Please input sheet name.")
ActiveSheet.Name = SheetName
End With
End Sub