Fill in the start date and end date with each list name with vba

roykana

Active Member
Joined
Mar 8, 2018
Messages
311
Office Version
  1. 2010
Platform
  1. Windows
Dear All Master ,

Please help me to fill in the start and end dates that have been specified in the vba sheet in column B that I marked the color based on the list of names in the vba sheet in column B that I marked the color. The result is in sheet 2 in column A & B which I marked green. I want to be able to use VBA so that it is not manual and just click the button that has the VBA sheet. In sheet 1 in the c & d column that I marked in red I want to be able to use the formula if an error (#value) occurs, then the format of the region is changed to Indonesian.
This is my link : ABSENSI 2004.xlsm

Thanks

kana
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi

Try the below code to put your data from sheet VBA to sheet2 ... I didn't understand what you need to accomplish for sheet1 though

VBA Code:
Sub Button1_Click()

Dim a, Cnt&, sDate&, eDate&, s, i&

With Sheets("VBA")
   sDate = .Range("B1")
   eDate = .Range("B2")
   Cnt = eDate - sDate + 1
   a = .Range("D2", .Range("D" & Rows.Count).End(3))
End With

i = 2
With Sheets("Sheet2")
   For Each s In a
      .Cells(i, "A").Resize(Cnt) = s
      .Cells(i, "B").Resize(Cnt) = Evaluate("row(1:" & Cnt & ")+" & sDate - 1 & "")
      i = i + Cnt
   Next
End With

End Sub
 
Upvote 0
Hi

Try the below code to put your data from sheet VBA to sheet2 ... I didn't understand what you need to accomplish for sheet1 though

VBA Code:
Sub Button1_Click()

Dim a, Cnt&, sDate&, eDate&, s, i&

With Sheets("VBA")
   sDate = .Range("B1")
   eDate = .Range("B2")
   Cnt = eDate - sDate + 1
   a = .Range("D2", .Range("D" & Rows.Count).End(3))
End With

i = 2
With Sheets("Sheet2")
   For Each s In a
      .Cells(i, "A").Resize(Cnt) = s
      .Cells(i, "B").Resize(Cnt) = Evaluate("row(1:" & Cnt & ")+" & sDate - 1 & "")
      i = i + Cnt
   Next
End With

End Sub
Dear sir

thank you for the solution you made. can you add a VBA CODE with progress status and success status.
for sheet 1 I want the results that I marked red with the formula. for new state, fill in C / Out means the second or last time or if a single or one time appears C / Out. You can see in column i that counts with the count if formula.

Thanks
kana
 
Upvote 0
Hi kana,

In your sample file, Sheet1 column B has an invalid date time format 21/03/2020 07.55 & therefore, your count if formula in column 'i' returns 1 for all examples. You have 'state' in column C which is always C/In & in some instances of column D (New State), you have C/Out which I can't link to the formula of column i ?

Sorry, it is still not clear to me what you're trying to do or what macro should I do to fulfil your requirements
 
Upvote 0
Dear sir,
can you add a VBA CODE with message box, progress status and success status. I want to ask if I use column d, that is, list names of more than one column such as id and others, how about the vba code ?. I'm a beginner, I want to learn a lot from you. For the formula, I passed it first because I wasn't in front of the laptop and I replied using my cellphone.
Thankslater I make sure to explain in detail about c / in and c / out maybe you have the best solution
thanks
Kana
 
Upvote 0

Forum statistics

Threads
1,215,592
Messages
6,125,713
Members
449,253
Latest member
Mbogo

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